0

I have a method that export to csv. and I have a list with default values. The problem is that the default values go into one column, and I want them to go into a single row. enter image description here

list = ['test1', 'test2, 'test3']
Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
  • Hi, please look at this once https://stackoverflow.com/questions/14037540/writing-a-python-list-of-lists-to-a-csv-file – Anup May 30 '17 at 15:06

1 Answers1

0
import csv
l = ['test1', 'test2', 'test3']
with open('eggs.csv', 'wb', newline='') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=',',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(l)

You'd better not use list as a variable name, since it collides with python's internal list function.

zwer
  • 24,943
  • 3
  • 48
  • 66
lkahtz
  • 4,706
  • 8
  • 46
  • 72