Reputation: 9
I'm trying to export numbers in row of csv. However, doesnt matter if I want to print it in row or columes, they are all limited by size 5. If the writer exccess 5 , it will rewrite them again. I want csv to record all lines I want to write, not only last 5 lines. This is the code I wrote:
with open('Testing.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(str(lencenters))
Upvotes: 0
Views: 101
Reputation: 21
Try not to convert the lencenters to str like
writer.writerows(lencenters)
The lencenters should be a list of lists representing row fields.
Upvotes: 1
Reputation: 2819
It works for me with:
import csv
with open('Testing.csv', 'w', newline='') as file:
writer = csv.writer(file)
for i in range(0,20):
writer.writerows([[i]])
Upvotes: 0