[Python-ideas] csv.DictReader could handle headers more intelligently.
Stephen J. Turnbull
stephen at xemacs.org
Fri Jan 25 03:38:30 CET 2013
Steven D'Aprano writes:
> - it adds burden to the caller, since the caller is now expected to
> manually inspect the field names and decide whether some should
> be discarded;
It's a dirty job but somebody has to do it.
And that ultimately has to be the *writer* of the CSV file, not the
reader. Both csv.DictReader and the caller are merely guessing unless
there's a private agreement with the writer. cvs.DictReader, as a
stdlib module, can't know about that agreement. The caller can
(although one obvious use case for csv.DictReader is that the caller
doesn't and is hoping csv.DictReader can guess better, oops).
Unless somebody has figured out how to give stdlib code "channeling"
capability?
More information about the Python-ideas
mailing list