Writing a nice formatted csv file

7stud bbxx789_05ss at yahoo.com
Wed May 2 10:26:07 EDT 2007


On May 2, 8:14 am, redcic <cedric.lou... at gmail.com> wrote:
> 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

cvs files are constructed for efficient processing not formatting so
that you can read them easier.  If you want a formatted file, then
construct one.




More information about the Python-list mailing list