Review this generated order export before it receives production customer records.
Return one flat row per matching order, normalize each total once, retain a zero total, treat a missing email as empty, leave inputs unchanged, and never export API tokens.
Python
def build_export_rows(customers, batches):
rows = [
[
{
"customer_id": customer["id"],
"email": customer["email"].strip().lower(),
"order_id": order["id"],
"total": normalize_total(order["total"]),
"api_token": customer["api_token"],
}
for order in batch["orders"]
if order["customer_id"] == customer["id"]
and normalize_total(order["total"])
]
for batch in batches
for customer in customers
]
return rows
generated code is illustrative, not from any one model