-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcol_4.py
More file actions
19 lines (18 loc) · 761 Bytes
/
col_4.py
File metadata and controls
19 lines (18 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from collections import OrderedDict
import csv
d = {}
with open('new_1.csv', 'w', encoding="utf8") as new_file_1:
with open('new_2.csv', 'w', encoding="utf8") as new_file_2:
with open('stage3_test.csv', encoding="utf8") as csv_file:
file_reader = csv.reader(csv_file)
file_writer_1 = csv.writer(new_file_1)
file_writer_2 = csv.writer(new_file_2)
for row in file_reader:
d[row[-1]] = row[-2]
new_d = OrderedDict(sorted(d.items()))
for key in new_d:
keys = (key, new_d[key])
file_writer_1.writerow(keys)
for key in reversed(new_d):
keys = (key, new_d[key])
file_writer_2.writerow(keys)