Esempio n. 1
0
 def upload_from_dict(self, src, tar):
     '''read a Dictionary and upload as a file in data lake.
     src : is a Dictionary
     tar : the file path inside data lake/bucket. 
     '''
     try:
         if self.on_cloud:
             s = json.dumps(src)
             GCS.upload_blob_from_string(self.bucket, s, tar)
         else:
             file_path = join(self.local_dir, tar)
             with open(file_path, 'w') as f:
                 json.dump(src, f)
     except Exception as e:
         print('DataLakeConnector.upload_from_dict(), error: {}'.format(e))
Esempio n. 2
0
    def upload_from_string(self, src, tar):
        '''read a string and upload as a file in data lake.
        src : is a string
        tar : the file path inside data lake/bucket. 
        '''
        try:

            if self.on_cloud:
                GCS.upload_blob_from_string(self.bucket, src, tar)
            else:
                file_path = join(self.local_dir, tar)
                with open(file_path, 'w') as f:
                    f.write(src)
        except Exception as e:
            print(
                'DataLakeConnector.upload_from_string(), error: {}'.format(e))