PEP 305 - CSV File API

Dave Cole djc at object-craft.com.au
Sun Feb 2 04:04:20 EST 2003


>>>>> "Tyler" == Tyler Eaves <tyler at cg1.org> writes:

Tyler> Paul Rubin unleashed the following on comp.lang.python:
>> 
>> Implementing CSV correctly and generally involves getting a lot of
>> little details like that right.  And if you code it in pure Python,
>> by the time you handle all those cases, you get pretty poor
>> performance.

Been there, done that.

I ended up writing the Object Craft CSV parser after I had spent
around a week's worth of 30 minute waits parsing database extracts
using Python which came via Excel files (don't ask).

>> So it's better to code it in C and put it in the library once and
>> for all.

Amen.

Tyler> Well, why I work the standard delimeter is a | (pipe), and no
Tyler> quotes. So many of those problems don't come up...

"many" being the operative word.  It only takes one problem for the
scheme to fall down.

Tyler> Now if it could only get some of the old COBOL guys to
Tyler> understand that when dealing with delimited files, padding
Tyler> fields isn't nessesary ;)

Tyler> (Oh, and look at my post, I do mention being (mildly) in
Tyler> support of this as a library module ;)

Check the examples on this page:

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

CSV is pretty simple until you have to parse some which came from MS
Excel or MS Access where multi-line fields have been entered by the
user.

The PEP is basing the parser on the Object Craft CSV parser.

- Dave

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




More information about the Python-list mailing list