I am starting Python. Now I'm trying to find out why the second "for" loop does not work in the following script. I mean, I could only get the result of the first cycle βforβ, but none of the second. I copied and pasted the script and csv data into the following.
It will be useful if you tell me why this happens and how to make a second for for loop.
My SCRIPT:
import csv
file = "data.csv"
fh = open(file, 'rb')
read = csv.DictReader(fh)
for e in read:
print(e['a'])
for e in read:
print(e['b'])
"data.csv":
a,b,c
tree,bough,trunk
animal,leg,trunk
fish,fin,body
source
share