I am reading a csv file into a variable data like this:
def get_file(start_file): #opens original file, reads it to array
with open(start_file,'rb') as f:
data=list(csv.reader(f))
data is the entire csv file. How do I add an extra column to this data?
Short answer: open up the CSV file in your favourite editor and add a column
Long answer: well, first, you should use
csv.readerto read the file; this handles all the details of splitting the lines, malformed lines, quoted commas, and so on. Then, wrap the reader in another method which adds a column.Edit
As you asked in your other question:
which you use like