scripts: Reverted csv read/writing to pass notes through

On second thought, let's keep the more complicated results contained in
the json format. No reason to create complexity we don't need.

Note this also rips note parsing out of csv.py's collect_csv. Now all
scripts should ignore note fields in csv files, but accept note fields
in json files.

The impl is still in the history if we want to revert this in the
future.
This commit is contained in:
Christopher Haster
2026-03-05 10:19:14 -06:00
parent ecc72e3dba
commit 63d047484a
9 changed files with 44 additions and 163 deletions
+4 -19
View File
@@ -1894,9 +1894,7 @@ def collect_csv(csv_paths, *,
and v.strip()}
# special handling for notes field
if notes is not None and notes in r:
r_[notes] = set(n.strip()
for n in r[notes].split(',')
if n.strip())
r_[notes] = set(r[notes].split(','))
results.append(r_)
# read json?
@@ -2634,13 +2632,7 @@ def read_csv(path, Result, *,
and r[k].strip()}
| {k: r[prefix+k] for k in fields
if prefix+k in r
and r[prefix+k].strip()}
| ({Result._notes: set(n.strip()
for n in r[Result._notes].split(',')
if n.strip())}
if hasattr(Result, '_notes')
and Result._notes in r
else {}))))
and r[prefix+k].strip()})))
except TypeError:
pass
return results
@@ -2706,9 +2698,7 @@ def write_csv(path, Result, results, *,
writer = csv.DictWriter(f, list(
co.OrderedDict.fromkeys(it.chain(
by,
(prefix+k for k in fields),
[Result._notes] if hasattr(Result, '_notes')
else [])).keys()))
(prefix+k for k in fields))).keys()))
writer.writeheader()
for r in results:
# note this allows by/fields to overlap
@@ -2718,12 +2708,7 @@ def write_csv(path, Result, results, *,
if getattr(r, k) is not None}
| {prefix+k: getattr(r, k).__csv__()
for k in fields
if getattr(r, k) is not None}
| ({Result._notes: ','.join(
getattr(r, Result._notes))}
if hasattr(Result, '_notes')
and getattr(r, Result._notes)
else {}))
if getattr(r, k) is not None})
# write json?
else: