Short answer: open up the CSV file in your favourite editor and add a column
Long answer: well, first, you should use csv.reader
to 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.
def get_file( start_file )
f = csv.reader( start_file )
def data( csvfile ):
for line in csvfile:
yield line + [ "your_column" ]
return data( f )
Edit
As you asked in your other question:
def get_file( start_file )
f = csv.reader( start_file )
def data( csvfile ):
for line in csvfile:
line[ 1 ] += "butter"
yield line
return data( f )
which you use like
lines = get_file( "my_file.csv" )
for line in lines:
# do stuff