-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfix_csv.py
More file actions
23 lines (21 loc) · 743 Bytes
/
Copy pathfix_csv.py
File metadata and controls
23 lines (21 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import csv
from pathlib import Path
# Test the fixed save_csv logic standalone
def save_csv_fixed(path, rows):
if not rows: return
all_keys = []
seen = set()
for row in rows:
for k in row.keys():
if k not in seen:
all_keys.append(k)
seen.add(k)
with open(path, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=all_keys, extrasaction="ignore")
writer.writeheader()
for row in rows:
filled = {k: row.get(k, "") for k in all_keys}
writer.writerow(filled)
print(f"Saved {len(rows)} rows -> {path}")
# Load the rows from the run (they were computed but CSV failed)
# Just re-run server.py with the fix applied