[Python-ideas] csv.DictReader could handle headers more intelligently.

Yuval Greenfield ubershmekel at gmail.com
Thu Jan 24 17:08:34 CET 2013


On Thu, Jan 24, 2013 at 5:11 PM, J. Cliff Dyer <jcd at sdf.lonestar.org> wrote:

> On Thu, 2013-01-24 at 13:38 +0100, Antoine Pitrou wrote:
> > > 1. Do any data conditioning by ignoring empty lines and lines of
> > > just field delimiters before the header row (consensus seems to be
> > > "no")
>
> Well, I wouldn't necessarily say we have a consensus on this one.  This
> idea received a +1 from Bruce Leban and an "I don't see any reason not
> to" from Steven D'Aprano.
>
>
Count me in that list as well.

If it were urllib handling a special case for a server you don't control
then fine. But it's a valid CSV file you can process yourself if you need
more control. We should keep DictReader simple. This is also a reason
against "CarefulDictReader". If you need to be more specific then use
csv.Reader.


>
> > > 2. Give an error when encountering a duplicate field name (which
> > > will lead to data loss when reading from the file) (consensus seems
> > > to be "yes")
>
> Mostly, but with a strong objection from Mark Hackett, and hesitation
> about altering current behavior from Amaury Forgeot d'Arc.
>

In that one too.

Maybe we should ask the people on this list
http://hg.python.org/cpython/log/5b02d622d625/Lib/csv.py

Yuval
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130124/d4b74000/attachment.html>


More information about the Python-ideas mailing list