BDEA_Aufgabe1/Preprocess/01_addIds.py

13 lines
386 B
Python

import csv
with open("data/passengers_noid.csv", 'r') as input, open('data/passengers.csv', 'w') as output:
reader = csv.reader(input, delimiter = ',')
writer = csv.writer(output, delimiter = ',')
all = []
row = next(reader)
row.insert(0, 'id')
all.append(row)
for k, row in enumerate(reader):
all.append([str(k+1)] + row)
writer.writerows(all)