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

Eric V. Smith eric at trueblade.com
Tue Jan 29 20:21:58 CET 2013


On 01/29/2013 02:19 PM, Stephen J. Turnbull wrote:
> Eric V. Smith writes:
> 
>  > Not true: I process some csv files just to translate them into another
>  > format, say tab delimited. I don't care about the column names,
> 
> Then you'd be nuts to use csv.DictReader!  csv.reader does exactly
> what you want.
> 
> DictReader is about transforming a data format from a sequence of rows
> of values accessed by position, one of which might be a header, to a
> headerless sequence of objects with values accessed by name.  If your
> use case doesn't involve access by name, it is irrelevant.

True. But my point stands: it's possible to read the data (even with a
DictReader), do something with the data, and not know the column names
in advance. It's not an impossible use case.

Eric.




More information about the Python-ideas mailing list