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

2009-01-29 Thread Kent Johnson
On Thu, Jan 29, 2009 at 12:21 PM, emmanuel.delaborde wrote: > On 29 Jan 2009, at 15:26, Kent Johnson wrote: >> What are you trying to do? Generally problems of the form >> for item in list1: >> if item in list2: >> # do something with item >> > > the first csv file is a list of rows like this

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

2009-01-29 Thread Kent Johnson
On Thu, Jan 29, 2009 at 8:55 AM, emmanuel.delaborde wrote: >> >> 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 No, in general iterators cannot be reset. >> but failing that you would need to change th

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