Re: [Tutor] Problem with nested for-in (Alan Gauld)

2009-01-29 Thread emmanuel.delaborde
I suspect that you need to reset the reader iterator to the start. I'm sure there will be something in the iterator protocol to do that but failing that you would need to change the inner loop to: for line2 in csv.reader(open("CATEGORYLIST.csv","r")) which will re-read the file and create a new

[Tutor] Problem with nested for-in

2009-01-29 Thread emmanuel.delaborde
Hello, I have the following snippet : lines = csv.reader(open("CATEGORY.csv","r")) lines2 = csv.reader(open("CATEGORYLIST.csv","r")) old_cats = [] for line in lines: stories = [] for line2 in lines2: if line2[1] == line[0]: stories.append(line2[0]) old_cats.appen