I have a csv file with 5 columns and I want to add data to the 6th column. The data that I have is in an array.
At the moment, the code that I have will insert the data that I would like to receive in the 6th column, only AFTER all the data that already exists in the csv file.
For example, I have:
wind, site, date, time, value 10, 01, 01-01-2013, 00:00, 5.1 89.6 ---> this is the value I want to add in a 6th column but it puts it after all the data from the csv file
Here is the code I'm using:
csvfile = 'filename' with open(csvfile, 'a') as output: writer = csv.writer(output, lineterminator='\n') for val in data: writer.writerow([val])
I thought using 'a' would add the data to a new column, but instead just put it after (βunderβ) all the other data ... I don't know what to do!
source share