Python: writing an entire row to a CSV file. Why does it work this way? -
i had exported csv nokia suite.
"sms","sent","","+12345678901","","2015.01.07 23:06","","text"
reading pythondoc, tried
import csv open(sourcefile,'r', encoding = 'utf8') f: reader = csv.reader(f, delimiter = ',') line in reader: # write entire csv row open(filename,'a', encoding = 'utf8', newline='') t: = csv.writer(t, delimiter = ',') a.writerows(line) it didn't work, until put brackets around 'line' i.e. [line].
so @ last part had
a.writerows([line]) why so?
the writerows method accepts container object. line object isn't container. [line] turns list 1 item in it.
what want use instead writerow.
Comments
Post a Comment