Define the import contract
A fictional ledger export supplies transaction_id, currency and amount as text. Its control sheet expects three rows in one currency with amounts 0.10, 0.20 and 1.70, for a total of 2.00. Record the currency and sign convention before loading it. Combining unrelated currencies into a single numeric total would be a semantic error even if every line parses correctly. This example concerns reconciliation, not trading returns or investment performance.
Parse money from the original text
For decimal amounts, construct Decimal values from the input strings instead of first converting them to binary floats. Choose the allowed precision and rounding policy with the responsible business owner. Reject nonfinite values and keep invalid rows in an exception list. Do not replace an unreadable amount with zero and continue as though it were a verified ledger value.
from decimal import Decimal
amounts = [Decimal(value) for value in ["0.10", "0.20", "1.70"]]
assert all(value.is_finite() for value in amounts)
assert sum(amounts, Decimal("0.00")) == Decimal("2.00")Check identity as well as totals
Reject or deliberately handle repeated transaction keys. A balanced total alone does not prove that the correct transactions were imported: a missing debit and a missing credit can cancel numerically. Compare row count, unique identifiers, amount totals and exception counts with the approved source. Keep the raw file identifier and checksum so a later reviewer can reproduce the input.
Release a checked version
Write the validated output to a new version, then make it available only after controls pass. If a source revision arrives, identify what changed and retain the previous approved version according to the applicable retention policy. Test malformed decimals, duplicate keys, currency mismatches and an interrupted write. These checks make a financial import explainable without claiming a financial return from using Python.

