CSV variable seems to reset

marc wyburn marc.wyburn at googlemail.com
Wed Jun 18 06:19:19 EDT 2008


Hi, I'm using the CSV module to parse a file using

whitelistCSV_file = open("\\pathtoCSV\\whitelist.csv",'rb')
whitelistCSV = csv.reader(whitelistCSV_file)
for uname, dname, nname in whitelistCSV:
          print uname, dname, nname

The first time I run the for loop the contents of the file is
displayed.  Subsequent attempts to run the for loop I don't get any
data back and no exception.

The only way I can get the data is to run whitelistCSV_file = open("\
\pathtoCSV\\whitelist.csv",'rb') again.

I'm stumped as to how I can get around this or work out what the
problem is, I'm assuming that the 'open' command buffers the data
somewhere and that data is being wiped out by the CSV module but
surely this shouldn't happen.

thanks, Marc.



More information about the Python-list mailing list