Esempio n. 1
0
    def download_as_string(self, src):
        '''read a file in data lake and download it to local machine.
        src : the file path inside data lake/bucket. 
        tar : file path in our local machine. Directories must exist.
        '''
        try:
            s = None
            if self.on_cloud:
                s = GCS.get_str_from_blob(self.bucket, src)
            else:
                file_path = join(self.local_dir, src)
                with open(file_path, 'r') as reader:
                    s = reader.read()
            return s

        except Exception as e:
            print(
                'DataLakeConnector.download_as_string(), error: {}'.format(e))