Right now I am using this code to copy all csv files from source to target.
import os
import shutil
file_extension = ".csv"
def copy_csv(source_folder, target_folder, file_extension):
for item in os.listdir(source_folder):
source_fn = os.path.join(source_folder, item)
if os.path.isdir(source_fn):
copy_csv(source_fn, os.path.join(target_folder, item), file_extension)
elif item.endswith(file_extension):
if not os.path.exists(target_folder):
os.makedirs(target_folder)
shutil.copyfile(source_fn, os.path.join(target_folder, item))