Unexpected behaviour of csv module

John Machin sjmachin at lexicon.net
Tue Sep 26 23:36:01 CEST 2006


Andrew McLean wrote:
> John Machin wrote:
> > 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!
>
> Unfortunately the bits I should change are in _csv.c

We must be talking about different things. IIRC we were talking about
stripping spaces off each field, in your own code. You said that
DictReader was a problem. This can be fixed by changing each of the 3
occurrences of
    row = self.reader.next()
in the DictReader.next method to
   row = [x.strip() for x in self.reader.next()]
or, less kludgedly, by defining a function or method to do that.

Cheers,
John




More information about the Python-list mailing list