scripts: csv.py: Fixed missing fields going undetected

There's a bit of a push and pull when it comes to typechecking CSV
fields in our scripts. On one hand, we want the flexibility to accepts
scripts with various mismatched fields, on the other hand, we _really_
want to know if a typo caused a field to be quietly replaced with all
zeros...

I _think_ it's safe to say: if no fields across _all_ input files match
a requested field, we should error.

But I may end up wrong about this. Worst case we can always revert in
the future, maybe with an explicit flag to ignore missing fields.
This commit is contained in:
Christopher Haster
2024-11-12 11:55:35 -06:00
parent 103b251ad8
commit f31f3fdd68
+6 -1
View File
@@ -1117,6 +1117,11 @@ def infer(fields_, results,
for k in fields))
types = {}
for k in fields__:
if k not in fields_:
print("error: no field %r?" % k,
file=sys.stderr)
sys.exit(2)
for t in [RInt, RFloat, RFrac]:
for r in results:
if k in r and r[k].strip():
@@ -1130,7 +1135,7 @@ def infer(fields_, results,
else:
print("error: no type matches field %r?" % k,
file=sys.stderr)
sys.exit(-1)
sys.exit(2)
# typecheck field exprs, note these may reference input fields
# with the same name