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.

This won't be quite what you want, since you've comma-aligned all of the
fields after the first, but it should be readable.

> > > Whereas what I'd like to get is:
> > > 1,    2,    3,
> > > 10,  20,   30
> >
> > > which is more readable.
<snip>
> >
> > 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.
<snip>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to