[Csv] PEP 305

Dave Cole djc at object-craft.com.au
Mon Jun 7 07:10:34 CEST 2004


Andrew McNamara wrote:
>>I've a problem that I can't make the new CSV module fix - embedded \r's in 
>>fields.  I'm parsing a format that allows \r and \n to be part of a field, if 
>>the field is quoted with "".  Looking at Modules/_csv.c, this is probably 
>>impossible....
> 
> 
> If I remember correctly, you are correct - the current parser won't allow
> you to do this.
> 
> One thing that became apparent very early on in the life of the
> csv parser is that there is no end to variety of formats that call
> themselves CSV!  We settled for something as close as we could make it
> to Excel's behaviour, with the odd concession to Access, and any other
> formats that were "easy", but that still leaves plenty of out in the cold.
> 
> Now that it's part of the Python core, it's a royal pain in the arse to
> change anything, although your change is probably harmless, and we have
> plenty of test cases. 
> 
> Dave - any idea why we disallowed CR within a quoted field?

Because I assumed that the only end-of-line related characters were 
actually ends of line.  I then assumed that you would feed the parser 
one line at a time.  I suppose the weak part of this "logic" is when you 
have data with different styles of end-of-line characters.

- Dave

-- 
http://www.object-craft.com.au


More information about the Csv mailing list