I want to write data to a csv file row by row :
Please find the code below:
with open('a.csv',mode='w') as csv_file:
fieldnames=['colA','colB','colC']
writer=csv.DictWriter(csv_file,fieldnames=fieldnames)
writer.write_row({'colA':data1,'colB':data2,'colC':data3})
The above code is inside a loop in which the data changes each time and i need to write to csv file in every loop. With this code my csv file is having only 1 line with the latest data. How do i modify the code to get multiple lines?