[Tutor] newb help reading lines from csv

eryksun eryksun at gmail.com
Mon Oct 22 21:39:30 CEST 2012


On Mon, Oct 22, 2012 at 3:28 PM, LZAntal <lzantal at gmail.com> wrote:
> On Oct 22, 2012, at 12:20 PM, "Dewhirst, Rob" <robdewhirst at gmail.com> wrote:
>
>> import csv
>> ifile = open('test.csv', "r")
>> reader = csv.reader(ifile)
>
> I believe csv module uses iterator so you need to run reader.seek(0) between the for loops

You have to reset the file iterator with ifile.seek(0). You might also
want a new reader if you care about the line_num attribute, but
otherwise you can keep using the same reader.


More information about the Tutor mailing list