Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import os
- import shutil
- import sys
- if len(sys.argv) < 1:
- print "provide CSV file argument, followed by target directory argument,",\
- " followed by which column to use from csv file (optional)"
- elif len(sys.argv) < 4:
- in_file = sys.argv[1]
- target_path = sys.argv[2]
- file_path_column_name = "file_path"
- elif len(sys.argv) == 4:
- in_file = sys.argv[1]
- target_path = sys.argv[2]
- file_path_column_name = "file_path"
- df = pd.read_csv(in_file)
- image_paths = list(df[file_path_column_name])
- if not os.path.exists(target_path):
- os.makedirs(target_path)
- def copyFromListToPath(src_paths, dest_path):
- for i in range(len(src_paths)): shutil.copy2(src_paths[i], dest_path)
- copyFromListToPath(image_paths, target_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement