我正在将数据写入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])
我做错了什么,我该如何解决这个问题?这似乎是一个简单的解决方案,但我很难过。
答案 0 :(得分:1)
entry = [VC_s, VC_i, VT_s]
rowAdd = tempfile.next()
ofile.writerow(rowAdd + entry)
答案 1 :(得分:0)
您只想要entry = [VC_s, VC_i, VT_s]