Skip to content

Instantly share code, notes, and snippets.

@martanto
Created March 7, 2020 12:53
Show Gist options
  • Save martanto/a8ed887effb7f11da123eb639f87b632 to your computer and use it in GitHub Desktop.
Save martanto/a8ed887effb7f11da123eb639f87b632 to your computer and use it in GitHub Desktop.
Transfer file multithreading
import os
import shutil
from multiprocessing.dummy import Pool as ThreadPool
from tqdm import tqdm
df['image'] = df['_id'].apply(lambda x:x+".jpg")
path = df['image'].tolist()
def move_file(pth):
shutil.move("/content/netaporter_gb/"+pth, "/content/netaporter_gb_images/"+pth)
batch = 2048
thread = 16
for i in tqdm(range(0,len(path),batch)):
pool = ThreadPool(thread)
pool.map(move_file, path[i:i+batch])
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment