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

J. Cliff Dyer jcd at sdf.lonestar.org
Thu Jan 24 16:23:24 CET 2013


On Thu, 2013-01-24 at 22:33 +1000, Nick Coghlan wrote:
> The problem with the latter suggestion is that it's a backwards
> incompatible change - code where "use the last column with that name"
> is the correct behaviour currently works, but would be broken if that
> situation was declared an error. 

One example where a programmer would legitimately want to ignore errors
of this kind: A CSV file has a number of named columns, and a few
unnamed ones, and the programmer doesn't care about data from the
unnamed columns.  The unnamed columns all have the same name (''), and
would raise this exception.  Hence the need to be able to suppress it
somehow (e.g., by instantiation argument or by catching the exception)
without losing the fieldnames.

Cheers,
Cliff







More information about the Python-ideas mailing list