我有一个 CSV 文件,其中包含如下数据:
a,b,c,d,e,f
0,0,AER,0,DME,0
0,0,ASF,0,LED,0
如何从 C 列和 E 列获取输入,并将它们输出为:
I like [column C] and [column E]
I like [column C] and [column E]
例子:
I like AER and DME
I like ASF and LED
现在我有以下代码:
import csv
header1 =['c']
header2 =['e']
with open('routes2.csv', 'rb') as csvfilein, open('out.csv', 'wb') as csvfileout:
reader = csv.DictReader(csvfilein)
writer1 = csv.DictWriter(csvfileout, header1, extrasaction='ignore')
writer2 = csv.DictWriter(csvfileout, header2, extrasaction='ignore')
for line in reader:
writer1.writerow(line), writer2.writerow(line)
我一直在试图弄清楚如何将文本附加到 C 和 E 列的数据中。我该怎么做?