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

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


On Thu, 2013年01月24日 at 07:28 -0800, Shane Green wrote:
> Since every form of CSV file counts EOL as a line terminator, I think
> discarding empty lines preceding the headers is arguably acceptable,
> but do not think discarding lines of just delimiters would be. What
> about extending the DictReader API so it was easy to perform these
> actions explicitly, such as being able to discard() the field names to
> be re-evaluated on the next line?

I think I like this idea. There's something a little distasteful about
making the user manually delve into the underlying reader, but this
makes it more user-friendly and more obvious how to proceed.
For clarity's sake, what is your objection to discarding lines of
delimiters? The reason I suggest doing it is that it is a common output
situation when exporting Excel files or LibreCalc files that have a
blank row at the top.
Cheers,
Cliff


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /