[Csv] ignore blank lines?

Skip Montanaro skip at pobox.com
Wed Feb 26 22:42:49 CET 2003


Returning to an old pre-vacation topic...

    >> Well, I would argue that a row of commas just means a row of empty
    >> strings.

    John> It can mean that the database has a row with all values NULL, or
    John> some other equally distrubing circumstance.

We've already established that there is no way to store NULL/None values in
a CSV file and have them be reliably reconstituted when the file is read
back in.

    >> Other than that, I agree, I wouldn't expect blank lines or lines with
    >> too few columns from properly function programs which are supposed to
    >> dump rows with constant numbers of columns.

    John> Exactly. Which makes me wonder why you have implemented defaults
    John> for short rows.

Perhaps it's just overkill.

    >> I guess my Python aphorism for the day is "Practicality beats
    >> purity."

    John> I don't understand this comment. You are advocating (in fact have
    John> implemented) hiding disturbing circumstances from the callers. Do
    John> you classify this as practical or pure?

If, for some reason, a row in a CSV file has a short line or a blank line I
don't want the processing to barf.  Most CSV files are program-generated,
and in my opinion the likelihood of a user introducing more problems into
the file by hand editing it are too high.  I'd rather worm around problems
in the files.

On output, I think it would be convenient to not require dictionaries being
dumped to the file to have a full complement of key-value pairs.  Not all
such data will be generated by a database which fully populates all fields.

Skip


More information about the Csv mailing list