-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_csv.py
More file actions
32 lines (24 loc) · 1.07 KB
/
clean_csv.py
File metadata and controls
32 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# import csv
# input_file = "telemetry_data.csv"
# output_file = "telemetry_data_clean.csv"
# expected_columns = 12 # Update this if your header has a different number of columns
# with open(input_file, "r", newline='') as infile, open(output_file, "w", newline='') as outfile:
# reader = csv.reader(infile)
# writer = csv.writer(outfile)
# for row in reader:
# if len(row) == expected_columns:
# writer.writerow(row)
# else:
# print(f"Skipping bad row: {row}")
# print("Cleaned file written to", output_file)
header = [
"angle", "trackPos", "speedX", "speedY", "speedZ", "rpm", "gear",
"track_edges", "opponents_data", "race_position", "damage", "distance_raced"
]
input_file = "telemetry_data.csv"
output_file = "telemetry_data_clean_with_header.csv"
with open(input_file, "r") as infile, open(output_file, "w") as outfile:
outfile.write(",".join(header) + "\n")
for line in infile:
outfile.write(line)
print("Header added. Use telemetry_data_clean_with_header.csv for your work.")