Closed riverscuomo closed 2 years ago
This happens because open()
ed files are iterables which can only be iterated once, and then they are exhausted.
To fix this, you could re-open the file for each job like this:
for job in jobs:
with open(ADD_LIST_FILE) as csvfile:
data = csv.DictReader(csvfile)
# work . . .
Or you could read the file into a list which you can iterate as many times as you want:
with open(ADD_LIST_FILE) as csvfile:
reader = csv.DictReader(csvfile)
data = list(reader)
for job in jobs:
# work . . .
I would go with something similar to the second option.
Fascinating. Yeah, I'll go with option two.
in main()