Built-in Stages¶
RenameFields¶
Renames dict keys according to mapping. Unmapped keys pass through unchanged.
Example:
# Input: {"{Report.Vendor}": "Acme", "{Report.Price}": "50.00"}
# Output: {"supplier": "Acme", "cost": "50.00"}
RenameFields({"{Report.Vendor}": "supplier", "{Report.Price}": "cost"})
CastTypes¶
Casts specified fields to the given types. Raises ValueError if a cast
fails.
Example:
# Input: {"invoice": "INV-001", "qty": "3", "price": "19.99"}
# Output: {"invoice": "INV-001", "qty": 3, "price": 19.99}
CastTypes({"qty": int, "price": float})
DropFields¶
Removes specified keys from each row.
Example:
FilterRows¶
Keeps only rows where predicate(row) returns True.
Example:
# Input: [{"amt": "10"}, {"amt": "200"}, {"amt": "50"}]
# Output: [{"amt": "200"}]
FilterRows(lambda r: float(r.get("amt", 0)) > 100)
Edge cases¶
- RenameFields: If a mapping key does not exist in the row, it is silently ignored. Duplicate target names are not checked, the last mapping wins.
- CastTypes: Raises
ValueErrorif a value cannot be cast to the target type. - DropFields: Dropping a non-existent key is a no-op.
- FilterRows: The predicate receives the row after all prior stages.