take two.

Take Two · AI in IT operations

A practical lab for creating a till report from CSV

Run a till report from CSV with Python: free download, fictional data, tests and an AI prompt. Handle missing data, duplicates and revisions.

Take Two · · 4 min read

A till and sales report should show both received amounts and missing tills. This lab lets you run a Python script on fictional data, open the report in a browser and see what changes when a late summary arrives.

The package contains the script, three CSV files, Italian and English instructions, fifteen automated tests and generated examples. Python calculates the results and prepares a prompt for commentary in your own AI tool.

Download and run the lab

Download the complete lab ZIP. All materials are free and available without an account.

You need Python 3.10 or later and a terminal. No extra libraries or API keys are required. The script uses local files and makes no network requests.

Extract the package, open a terminal in the extracted folder and run on Windows:

py report.py --inventory casse-attese.csv --uploads invii.csv --date 2026-10-07 --out result --lang en

On Linux or macOS, replace py with python3. The package also explains the python alternative on Windows.

Open the HTML file in the result folder. You can also view the generated sample report.

Understand the inputs

The first CSV lists four tills expected on the business date of 7 October 2026. The second contains received summaries, with receipts, gross, returns, revision and completeness. All identifiers and amounts are fictional.

These are whole-day summaries: revision 2 replaces revision 1 for a till. They are not incremental batches to add together. One duplicate and one superseded revision help demonstrate how to avoid double-counting.

The business date comes from the source system. The lab filters by that date without converting timestamps or timezones. Agree the expected till inventory and business-day rules before exporting operational data.

Check the first result

Measure Expected result
Complete out of expected tills 3 out of 4
Coverage 75%
Available receipts 295
Available gross EUR 11,800.00
Available returns EUR 300.00
Available net EUR 11,500.00
Missing till ST018 POS02

Net means gross less returns; it does not reconcile payments. The total is incomplete because a till is missing. ST017 has both tills and EUR 7,800.00 net. ST018 has one of two tills and EUR 3,700.00 available net.

Amounts are calculated in integer cents. A complete zero-sales summary counts towards coverage. An absent summary remains missing. If no till is complete, available totals are unavailable rather than zero.

Simulate a late arrival

The third CSV adds the missing ST018 POS02 summary:

py report.py --inventory casse-attese.csv --uploads invii-completi.csv --date 2026-10-07 --out result-complete --lang en

Coverage becomes 100%, receipts become 350 and net becomes EUR 13,700.00. The first report represented incomplete coverage. Retain both reports to see what changed.

Reusing the same output folder, date and language replaces the four generated files. Use different folders to keep report versions, as the examples do.

Add AI commentary

Each run creates HTML, Markdown, JSON results and a file ending in -ai-prompt.txt, containing instructions and calculated values.

Copy it into your authorised AI tool. Compare the response with the report: it should preserve coverage and available amounts, identify the missing till and avoid inventing faults or lost sales. The lab makes no model calls and contains no measured AI commentary.

The calculations remain verifiable if commentary generation fails. The HTML report works without AI.

Test errors before adapting the inputs

Fifteen included tests cover duplicates, revision order, late arrival, zero, missing data, invalid amounts and bilingual output:

py -m unittest test_report.py

You can also copy a CSV and change a value on a duplicated revision. The script should reject the conflict. Tests have been executed against the published package.

Before using operational data, align receipt, gross and returns definitions with your source system. The README documents headers, delimiters and number formats. Renaming an Excel file to CSV does not satisfy the input contract.

Read the daily till and sales report example for the method. Continue with the free structured prompts course, with a free account.

Continue exploring