Python CSV Record Column

I got this sample code:

import csv
w = csv.writer(file(r'test.csv','wb'), dialect='excel')
some_values=[(1,2,3)]
w.writerows(some_values)

When I open CSV in excel, I got all the values ​​in the same one column(A). I want to put the values ​​in A1, B1and C1. How can i do this?

MS Office Excel 2007 Service Pack 2 (SP2)

Thank.

DECISION:

w = csv.writer (file (r'test.csv ',' wb '), delimiter ='; ')

+5
source share
3 answers

w = csv.writer (file (r'test.csv ',' wb '), delimiter ='; ')

0
source

I have never used a CSV module before, but you set some_values ​​to a list of tuples.

So, the first element of the list is the tuple (1,2,3).

Should you use just a list [1,2,3] or a tuple (1,2,3)?

+1

, :
w.writerows([1, 2, 3]).
1 - 3 .

0

All Articles