Sep-20-2017, 03:19 PM
I'm using the following code to read a tiny csv file into a Dictionary and then print part of it twice. The first print works but the second print seems to do nothing despite it being identical code. No error message is generated. What am I missing?
User,Password
James,1234
Will,5678
Fred,1111
Harry,3333
import csv UserDB = {} FileName = 'UserDB.csv' UserDB = csv.DictReader(open(FileName, 'r'), delimiter=',', quotechar='"') for line in UserDB: print (line['User']) for line in UserDB: print (line['User'])The csv file just contains..
User,Password
James,1234
Will,5678
Fred,1111
Harry,3333