What's the best way to extract 2 values from a CSV file from each row systematically?

Roland Mueller roland.em0001 at googlemail.com
Fri Sep 27 05:22:48 EDT 2013


Hello,

2013/9/24 Alex Lee <quarantinemiles at gmail.com>

> Thanks for the help guys! I'll definitely read up on the csv module
> documentation.
>
> Tim, that's incredibly helpful, thanks a lot! :) My CSV file doesn't have
> headers, but I'm sure I can just as easily add it in manually.
>

a better way to provide column headers is to use the fieldname parameter
when creating the CSV reader. fieldnames is a string array that should
match the number of columns in the csv file:

*class *csv.DictReader(*csvfile*, *fieldnames=None*, *restkey=None*, *
restval=None*, *dialect='excel'*, **args*, ***kwds*)

BR,
Roland

--
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130927/b6abf032/attachment.html>


More information about the Python-list mailing list