DLfile_6.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. def upload_files():
  2. adl = core.AzureDLFileSystem(adlCreds, store_name=config.store_name)
  3. uploadedFolders = adl.ls(adls_upload_folder_path)
  4. uploadedFolders = set([folder.replace(adls_upload_folder_path[1:], "")+"/" for folder in uploadedFolders])
  5. local_folders = glob.glob(local_upload_folder_path+"*") # * means all if need specific format then *.csv
  6. local_folders = set([d.replace(local_upload_folder_path, "")+"/" for d in local_folders])
  7. to_upload_folders = local_folders.difference(uploadedFolders)
  8. folder_names = sorted([d.replace(local_upload_folder_path, "") for d in to_upload_folders])
  9. files = []
  10. for folder in folder_names:
  11. path = local_upload_folder_path+folder
  12. for f in listdir(path):
  13. if isfile(join(path, f)):
  14. files.append(folder+f)
  15. print("Uploading the following folders:<br>{}<br>Total number of files to upload:<br>{}".format(", ". join(folder_names), len(files)))
  16. for f in files:
  17. adl.put(local_upload_folder_path+f, adls_upload_folder_path+f)
  18. print("Upload finished.")
  19. time.sleep(2)
  20. global uploaded_files
  21. uploaded_files = True