csv - Python: Write list to individual columns in each row -
i'm writing data csv current output follows: (the top row headers)
vc_s vc_i vt_s 1 (['not reported'],['reported'],['click']) 2 (['not reported'],['reported'],['click'])
the desired output follows:
vc_s vc_i vt_s 1 not reported reported click 2 not reported reported click
the code i've got far is:
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")) row in ifile: #do 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])
what doing wrong , how can fix this? seem easy fix stumped.
entry = [vc_s, vc_i, vt_s] rowadd = tempfile.next() ofile.writerow(rowadd + entry)
Comments
Post a Comment