[Tutor] Writing long strings (that include commas) to a csv file
Judith Flores
juryef at yahoo.com
Thu Jan 22 20:33:20 CET 2009
Hello dear Python experts,
How can I write a complete string (which sometimes will include many commas) to a cell in a CSV file? With the code below, what I obtain is a cell per letter of every string:
file1=open('myfile.csv','w')
writer=csv.writer(file1)
mylist=[ " first , txt+words , more" , " second, text + words, and more"]
listnumbers=["0","5"]
for i in range(0,len(mylist)):
writer.writerow(mylist[i] + listnumbers[i])
file1.close()
So the first element of mylist should fill up only one cell in the csv file, and the same for the second elemente, and so on.
Any help would be very much appreciated.
Thank you!
Judith
More information about the Tutor
mailing list