I have a list of lists of pure data like this
a=[[1,2,3],[4,5,6],[7,8,9]]
How can I write a
into a CSV file with each list in a column like this?
1 4 7
2 5 8
3 6 9
I have a list of lists of pure data like this
a=[[1,2,3],[4,5,6],[7,8,9]]
How can I write a
into a CSV file with each list in a column like this?
1 4 7
2 5 8
3 6 9
Use:
import csv
with open('output.csv', 'w', newline='') as csvfile:writer = csv.writer(csvfile)writer.writerows(list(zip(*l)))