Skip to content

Instantly share code, notes, and snippets.

@yongjun823
Created November 17, 2018 06:22
Show Gist options
  • Select an option

  • Save yongjun823/91112d015fa4c074baaeba4f27217489 to your computer and use it in GitHub Desktop.

Select an option

Save yongjun823/91112d015fa4c074baaeba4f27217489 to your computer and use it in GitHub Desktop.
python csv concat open image style
import os
CSV_FOLDER = 'csvs/'
def parse_csv(csv_path):
arr = []
csv_arr = open(csv_path, encoding='utf-8')
next(csv_arr)
for i in csv_arr:
arr.append(i)
return arr
def write_result_csv(csv_data):
with open('result.csv', 'w', encoding='utf-8') as f:
f.write('image_id,original_url\n')
for i in csv_data:
f.write(i)
csv_arr = [CSV_FOLDER + x for x in os.listdir(CSV_FOLDER)]
new_arr = []
for ca in csv_arr:
a1 = parse_csv(ca)
new_arr += a1
print(len(new_arr))
write_result_csv(new_arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment