Re: Writing a nice formatted csv file

2007-05-02 Thread Dave Borne
> Whereas what I'd like to get is: > 1,2,3, > 10, 20, 30 (without trying this myself first...) You might try setting up a csv dialect with a delimiter of ',\t' then using a reader that can set tab stops for display. -Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a nice formatted csv file

2007-05-02 Thread Jon Clements
On 2 May, 15:14, redcic <[EMAIL PROTECTED]> 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 > >

Re: Writing a nice formatted csv file

2007-05-02 Thread dustin
On Wed, May 02, 2007 at 07:28:32AM -0700, redcic wrote: > Well then how can I format a file ? for row in rows: print "".join([ "%-6s" % ("%d," % cell) for cell in row ]) The "%-6s" formats each column to be no less than six characters long; the "%d," formats the number with a comma after it.

Re: Writing a nice formatted csv file

2007-05-02 Thread redcic
Well then how can I format a file ? Thanks for your help, Cédric On 2 mai, 16:26, 7stud <[EMAIL PROTECTED]> wrote: > On May 2, 8:14 am, redcic <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > > I use the csv module of Python to write a file. My code is of the > > form : > > > cw = csv.writer(ope

Re: Writing a nice formatted csv file

2007-05-02 Thread 7stud
On May 2, 8:14 am, redcic <[EMAIL PROTECTED]> 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 >

Re: Writing a nice formatted csv file

2007-05-02 Thread Sebastian Bassi
On 2 May 2007 07:14:04 -0700, redcic <[EMAIL PROTECTED]> wrote: > 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. The idea behind csv module is to produce and read csv files that are "machine r

Writing a nice formatted csv file

2007-05-02 Thread redcic
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 mor