Writing a nice formatted csv file

redcic cedric.louyot at gmail.com
Wed May 2 10:28:32 EDT 2007


Well then how can I format a file ?

Thanks for your help,

Cédric

On 2 mai, 16:26, 7stud <bbxx789_0... at yahoo.com> wrote:
> 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