BDEA_Aufgabe1/Preprocess/01_addIds.py

13 lines
386 B
Python
Raw Normal View History

2024-04-18 08:36:22 +02:00
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)