Andrew McLean wrote:
> John Machin wrote:
> > A better workaround IMHO is to strip each *field* after it is received
> > from the csv reader. In fact, it is very rare that leading or trailing
> > space in CSV fields is of any significance at all. Multiple spaces
> > ditto. Just do this all the time:
> >
> > row = [' '.join(x.split()) for x in row]
>
> The problem with removing the spaces after they are received from the
> csv reader is if you want to use DictReader. I like to use DictReader,
> without passing it the field list. The module then reads the field list
> from the first line, and in this situation you don't get an opportunity
> to strip the spaces from that.

You can fix that. The beauty of open source is that you can grab it
(Windows: c:\python2?\lib\csv.py (typically)) and hack it about till it
suits your needs. Go fer it!

Cheers,
John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to