Created
November 17, 2018 06:22
-
-
Save yongjun823/91112d015fa4c074baaeba4f27217489 to your computer and use it in GitHub Desktop.
python csv concat open image style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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