I have csv file. It does not have column names. I need to append new column at the start of the row. I mean array[0]. I am new to this. Please help me.
This is the csv file I have
1,100,303,619,figure
338,162,143,423,text
85,768,554,39,text
504,164,24,238,subtitle
I just want to add new column Record like this
Record_01,98,87,544,396,figure
Record_02,98,488,91,48,caption
Record_03,98,568,142,254,figure
Record_04,97,834,8,6,page
I have tried this code it doesn't work. it doesn't show error message. But it doesn't change anything.
key = []
for row, Record in enumerate(key):
print('Record_{}'.format(row, Record))
row.append(row[0])
key.appen(row)
with open('csvfiles', 'r') as csvinput:
with open('csvfiles', 'w') as csvoutput:
writer = csv.writer(csvoutput, delimiter=',')
writer.writerow[key]
Highly appreciate for any answers.