[Tutor] Enumerate vs DictReader object manipulation:
Matt Williams
matt.williams45.mw at gmail.com
Thu Feb 4 01:45:15 EST 2016
Just as a note - you are not the only person caught out by this - it is a
very common slip.
I wonder whether it would be worth adding a more explicit line about this
in the Python Docs?
Matt
On Wed, 3 Feb 2016 16:13 Ek Esawi <esawiek at gmail.com> wrote:
> Hi All
>
>
>
>
>
> I have a code that reads a csv file via DictReader. I ran into a peculiar
> problem. The python interpreter ignores the 2nd code. That is if I put the
> reader iterator 1st, like the code below, the enumerate code is ignored; if
> I put the enumerate code 1st, the reader code is ignored. I am curious to
> know the nature of such behavior. EKE
>
>
>
> Here part of my code:
>
>
>
> .
>
> .
>
> .
>
> reader = csv.DictReader(MyFile)
>
> for row in reader:
>
> list_values = list(row.values())
>
> print (list_values)
>
>
>
> for i,j in enumerate(reader):
>
> print(j)
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list