Re: Unexpected behaviour of csv module

2006-09-26 Thread John Machin
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

Re: Unexpected behaviour of csv module

2006-09-26 Thread Andrew McLean
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 and, as I'm not very proficient at C, that wouldn'

Re: Unexpected behaviour of csv module

2006-09-25 Thread John Machin
[EMAIL PROTECTED] wrote: > One could argue that your CSV file is broken. Hi Skip, His CSV file is mildly broken. The examples that I gave are even more broken, and are typical of real world files created by clueless developers from databases which contain quotes and commas in the data (e.g. addre

Re: Unexpected behaviour of csv module

2006-09-25 Thread skip
One could argue that your CSV file is broken. Of course, since CSV is a poorly specified format, that's a pretty weak statement. I don't remember just what your original problem was, but it concerned itself with white space as I recall. Have you tried setting the skipinitialspace parameter in yo

Re: Unexpected behaviour of csv module

2006-09-25 Thread John Machin
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 tim

Re: Unexpected behaviour of csv module

2006-09-25 Thread Andrew McLean
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(

Re: Unexpected behaviour of csv module

2006-09-24 Thread John Machin
Andrew McLean wrote: > I have a bunch of csv files that have the following characteristics: > > - field delimiter is a comma > - all fields quoted with double quotes > - lines terminated by a *space* followed by a newline > > What surprised me was that the csv reader included the trailing space in

Unexpected behaviour of csv module

2006-09-24 Thread Andrew McLean
I have a bunch of csv files that have the following characteristics: - field delimiter is a comma - all fields quoted with double quotes - lines terminated by a *space* followed by a newline What surprised me was that the csv reader included the trailing space in the final field value returned,