Before handing an invoice CSV to an accountant, create an exception report that flags missing references, repeated supplier/reference pairs and amounts that do not fit the agreed input format. Preserve every row and its source reference. A flagged row needs investigation; an unflagged row is not approved for import, posting or payment.
The free kit above contains eight fictional invoice records, a blank CSV, a local Python checker and its expected JSON report. You can also apply the same rules manually in a controlled sheet or text editor. No AI model, paid subscription, bookkeeping integration or real client record is required. This is an administrative preparation exercise; a qualified accountant remains responsible for professional conclusions.
Agree a narrow input contract
Start with an export you are authorized to handle, stored under your firm’s access and retention rules. Keep the original unchanged. Make a restricted working copy and keep source evidence in the approved document system. Use stable IDs in the working sheet rather than copying bank details, account numbers or invoice images into a general task tracker.
This tutorial expects a UTF-8, comma-separated CSV with six headers in this exact order:
row_id,supplier_id,invoice_ref,currency,gross_amount,source_ref
row_id identifies one exported record and must be nonblank and unique. supplier_id is the firm’s stable supplier identifier, not a fuzzy name match. invoice_ref preserves the source reference, including leading zeros and punctuation. source_ref points an authorized reviewer to the original record; the fictional SYN-SOURCE values in the kit are illustrative IDs, not working links.
For this exercise only, gross_amount uses an optional minus sign, one to twelve digits, a decimal point and exactly two decimal places. Thousands separators, scientific notation and currency symbols are rejected. currency must have three uppercase letters, but this checks its format, not whether it is a valid code. The two-decimal convention is a teaching input contract, not a rule for every currency or invoice. If your export differs, ask the qualified reviewer to define an adaptation rather than rounding, stripping signs or guessing the currency.
Decide what each flag means
The checker preserves one report entry per input row. A blank required value receives a MISSING_... flag. A malformed nonblank amount receives INVALID_AMOUNT_FORMAT. A valid negative amount receives CREDIT_OR_NEGATIVE_REVIEW, since a negative record may need explanation or be a legitimate credit rather than an error.
For repeated references, the checker groups rows by supplier ID plus invoice reference, trimming surrounding whitespace and comparing case-insensitively. If a key repeats, it flags every member of the group as REPEATED_SUPPLIER_REFERENCE; it does not pick a winner or delete a row. It leaves punctuation and leading zeros intact. A repeated reference for a different supplier is a different key.
This is deliberately narrower than a complete duplicate-invoice control. Oracle’s official explanation of additional duplicate checks uses several attributes, illustrating why the invoice number alone is insufficient. Our sample is not an implementation of Oracle’s controls. Different references, supplier aliases or a prior invoice outside this file can evade this check; identical keys can also need legitimate explanation.
- Keep the originalUse stable row and evidence IDs in an authorized working copy.
- Report every rowCheck required fields, the declared amount format and repeated supplier/reference keys.
- Resolve with evidenceA qualified reviewer checks originals and decides what may enter the next process.
Run the supplied example without buying anything
Download and extract the kit. Open sample.csv, README.md and check_csv.py in a text editor first. The script uses Python 3.11+ and its standard library. It reads the supplied file and prints a JSON report; it does not change the CSV, call an API, import an invoice or send a payment.
From the extracted folder, run:
python3 check_csv.py sample.csv > report.json
Open report.json as text and compare it with expected-report.json. The first two counts should both be eight. Exit code 0 means the scan completed, including when row flags exist. You must read the report to see exceptions. Do not interpret successful execution as clean data.
The manual route uses the same six columns. Read each row, record blank or malformed fields, then compare the supplier/reference keys across the whole file. Write one finding entry for every row, including NO_RULE_FLAGS where appropriate. Keep a separate reviewer log with row ID, issue, source evidence, resolution, reviewer and timestamp. The supplied example is small enough to reconcile by hand.
Reconcile the eight fictional rows
I01 and I02 both refer to supplier SUP-A and invoice INV-010; the second includes different case and surrounding spaces. Both are flagged. I03 also has INV-010, but belongs to SUP-B, so it is not in that pair. I04 has no invoice reference and receives MISSING_INVOICE_REF. Do not invent one from the row number.
I05 has the quoted amount "1,200.00". It is valid CSV text but fails this exercise’s amount contract because it contains a thousands separator. The correct response is to check the original source, not assume every comma should be deleted. I06 has -20.00; it is parsed as a valid amount and flagged for credit/negative review. Do not remove the sign to make it look ordinary.
I07 has 30.00 in EUR and no rule flags. It remains a separate currency and is not added to a USD balance. I08 has no currency and receives MISSING_CURRENCY. The checker computes no financial totals, tax, exchange conversion or account classification. NO_RULE_FLAGS on I03 and I07 means only that these local rules found nothing; it does not establish that either invoice is genuine or correct.
Recover a failure without erasing evidence
Suppose a reviewer opens the source for I05 and confirms that the intended amount is 1200.00 in the declared currency. Record that source check and normalize the value in a new authorized working copy. Rerun the checker and compare the old and new reports. The formatting flag should disappear while the other unresolved findings remain. Keep the original export and the reason for the transformation.
For I01 and I02, compare the originals and the approved accounting system. A repeated key may reflect the same export row twice, a corrected record or another issue. The script cannot decide which one to retain. The reviewer must document the actual resolution through the firm’s normal process; no automated deletion follows from this flag.
An empty file, wrong header order, inconsistent field count, malformed CSV, duplicate or absent row IDs, or more than the teaching limit of 10,000 rows stops the scan with exit code 2. With output redirection, a failed command may still leave an empty report.json. Discard it as a failed run and correct the working input before trying again. File existence is not evidence of a complete report.
Handle spreadsheet and export edge cases
Do not split a CSV line on commas yourself: quoted commas are part of field values, as I05 demonstrates. The implementation follows Python’s CSV reader documentation, including newline handling. It uses decimal arithmetic for the amount-sign check rather than turning amounts into binary floating-point values. It does not calculate a balance.
Supplier aliases and references such as INV-010 versus INV010 remain distinct. That avoids aggressive normalization, but also means some related records will not be grouped. Put suspected variations in the reviewer log rather than silently rewriting them. Blank supplier or invoice-reference fields cannot form a reliable duplicate key and stay as missing-field findings.
If you inspect an unfamiliar export in a spreadsheet, use your firm’s safe import procedure and preserve text identifiers so leading zeros are not lost. Treat formula-like cell contents as untrusted data. The kit emits JSON for text inspection, not a spreadsheet with executable formulas. No script can make an unauthorized export or an insecure shared folder acceptable.
Use automation at the right boundary
A recurring exception report can be a useful deterministic first step before considering AI. An assistant might later draft an administrative explanation from approved minimal metadata, but should not decide accounting treatment, alter originals, approve payment or resolve a duplicate without qualified review. There is no need to purchase AI to complete this tutorial.
If the existing workflow needs custom support, describe the export format, exception types and reviewer handoff without sending client records. Let’s Create AI scopes licensed deployable software for client-hosted or assisted deployment; clients pay external AI model/API/subscription costs separately where used. No vendor integration or saving is promised here.
Checked: the eight synthetic rows, expected report, quoted-comma handling, deliberate structural failures, recovery on a copy and rendered page. Not tested: real invoices, OCR, a firm’s secure configuration, a vendor import, financial accuracy, tax treatment or a payment. Official documentation was reviewed on November 7, 2026; this method makes no jurisdictional compliance claim.
Join the conversation
Questions & comments
Reviewed before publication. No account needed.
Comments will load when you reach this section.
Leave a comment