feat(normalizer): overrides loader + xlsx/csv writers
Recovered from an entangled commit: these files were correct but had been bundled into an unrelated reader-dashboard commit by a concurrent session. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
21
tools/import-normalizer/overrides.py
Normal file
21
tools/import-normalizer/overrides.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Load human-supplied corrections. Missing files are not an error."""
|
||||
import csv
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def load_overrides(dates_path: Path, names_path: Path):
|
||||
date_overrides: dict[str, tuple[str, str]] = {}
|
||||
name_overrides: dict[str, str] = {}
|
||||
if Path(dates_path).exists():
|
||||
with open(dates_path, encoding="utf-8", newline="") as f:
|
||||
for row in csv.DictReader(f):
|
||||
raw = (row.get("raw") or "").strip()
|
||||
if raw:
|
||||
date_overrides[raw] = ((row.get("iso") or "").strip(), (row.get("precision") or "UNKNOWN").strip())
|
||||
if Path(names_path).exists():
|
||||
with open(names_path, encoding="utf-8", newline="") as f:
|
||||
for row in csv.DictReader(f):
|
||||
raw = (row.get("raw") or "").strip()
|
||||
if raw:
|
||||
name_overrides[raw] = (row.get("person_id") or "").strip()
|
||||
return date_overrides, name_overrides
|
||||
Reference in New Issue
Block a user