Reading from CSVs in Python repeatedly?

You can “reset” the CSV iterator by resetting the read position of the file object.

data = open("googlel.csv", "rb")
orig = csv.reader(data, delimiter=";")
goodrows = []
for feed in gotfeeds:    
   for link,comments in feed.items():
       data.seek(0)
       for row in orig:
           print link
           if link in row[1]:
               row.append(comments)
               goodrows.append(row)

Leave a Comment