【发布时间】:2011-02-11 05:13:48
【问题描述】:
我正在将数据写入 CSV,但当前输出如下: (最上面一行是标题)
A VC_s VC_i VT_s
1 (['Not Reported'],['reported'],['click'])
2 (['Not Reported'],['reported'],['click'])
期望的输出如下:
A VC_s VC_i VT_s
1 Not Reported reported click
2 Not Reported reported click
到目前为止我得到的代码是:
ifile = csv.reader(open("input.csv",'rb'))
shutil.copy("input.csv","temp")
tempfile = csv.reader(open("temp","rb"))
ofile = csv.writer(open("RESULTS.csv","ab"))
for row in ifile:
#do some table scraping stuff here
VC_s = str(cells[1].find(text=True))
VC_i = str(cells[2].find(text=True))
VT_s = str(cells[4].find(text=True))
entry = ([VC_s], [VC_i], [VT_s])
rowAdd = tempfile.next()
ofile.writerow(rowAdd + [entry])
我做错了什么,我该如何解决?这看起来很容易解决,但我很难过。
【问题讨论】: