I want to write data onto several rows in a csv file. With this code I am only getting a single line written onto file. Need help.
for i in range(1,10):
with open("output.csv",'wb') as f:
writer = csv.writer(f, dialect='excel')
writer.writerow([value1, value2, value3])
You are encountering the error because it is re-writing a csv for every iteration in your loop. You should move the with open() statement outside of your loop block.