Writing a nice formatted csv file

redcic cedric.louyot at gmail.com
Wed May 2 10:14:04 EDT 2007


Hi all,

I use the csv module of Python to write a file. My code is of the
form :

cw = csv.writer(open("out.txt", "wb"))
cw.writerow([1,2,3])
cw.writerow([10,20,30])

And i get an out.txt file looking like:
1,2,3
10,20,30

Whereas what I'd like to get is:
1,    2,    3,
10,  20,   30

which is more readable.

Can anybody help me to do so ?

Thanks,

Cédric




More information about the Python-list mailing list