[Python-ideas] csv.DictReader could handle headers more intelligently.
Mark Hackett
mark.hackett at metoffice.gov.uk
Thu Jan 24 17:23:50 CET 2013
On Thursday 24 Jan 2013, J. Cliff Dyer wrote:
> 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
>
I'm putting too many pennies in this pot, I feel, but...
What was the purpose of those blank lines? Like duplicate column names at the
first row, what you need to do with them depends on why they are there and what
the program using the output wants to do.
If someone took the repository of macros from the spreadsheet which used
column numbers and this was used to recreate EXACTLY whatever calculations
were done without having to keep two copies of the same algorithm to account
for the dropping of rows in the script, then dropping the rows would break
this.
This really is policy (wrt the source of the CSV and the consumer of the
dictionary).
Make it a pre process of the CSV to be used and configured to fit what the
meaning of the CSV file output was to the producing program and what bits of it
make a difference to the consumer of the dictionary's contents.
More information about the Python-ideas
mailing list