ideaplat
2016-05-30 14:07:51 +08:00
import csv
import json
fieldnames = ['rq',' 2000ZZ', ' 2000ZX', ' 202007', ' 202006', ' 202005', ' 202004', ' 202003', ' 202002', ' 202001', ' 202009', ' 202008', ' 20200G', ' 20200F', ' 20200E', ' 20200D', 'Map(2000ZY', ' 20200J', ' 20200I', ' 20200H', ' 602008', ' 602003', ' 602002', ' 602001', ' 602007', ' 602004', ' 20200a', ' 20200o', ' 20200n', ' 20200m', ' 20200l', ' 20200k', ' 20200j']
csv_file = open('0007A8A74A3A.csv', 'wb')
writer = csv.DictWriter(csv_file,fieldnames=fieldnames)
writer.writeheader()
with open("0007A8A74A3A.tsv") as tsv:
for line in csv.reader(tsv, dialect="excel-tab"):
res = dict([v.split(' -> ') for v in line[5].split(',')])
rq = {'rq':line[1]}
res.update(rq)
writer.writerow(res)