[Python-ideas] csv.DictReader could handle headers more intelligently. (original) (raw)
Ethan Furman ethan at stoneleaf.us
Fri Jan 25 04:20:23 CET 2013
- Previous message: [Python-ideas] csv.DictReader could handle headers more intelligently.
- Next message: [Python-ideas] csv.DictReader could handle headers more intelligently.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 01/24/2013 02:47 AM, Mark Hackett wrote:
On Thursday 24 Jan 2013, Steven D'Aprano wrote:
I'm not sure this behavior merits the all-caps "AS EXPECTED" label. It's not terribly surprising once you sit down and think about it, but it's certainly at least a little unexpected to me that data is being thrown away with no notice. It's unusual for errors to pass silently in python. Yes, we should not forget that a CSV file is not a dict. Just because DictReader is implemented with a dict as the storage, doesn't mean that it should behave exactly like a dict in all things. Multiple columns with the same name are legal in CSV, so there should be a reader for that situation. But just because it's reading a csv file, we shouldn't change how a dictionary works if you add the same key again.
The proposal is not to change how a dict works, but what the proper response is for DictReader when a duplicate key is found.
Ethan
- Previous message: [Python-ideas] csv.DictReader could handle headers more intelligently.
- Next message: [Python-ideas] csv.DictReader could handle headers more intelligently.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]