Work & productivity

Build a Python CSV summary script in Orlino

A comma inside an item name can break a script that splits CSV lines by hand. A blank price can cause a different problem: a report that looks complete even though an input was unusable. Give Orlino a small sample file, the exact calculation and the rules for rejecting bad rows before asking it to generate a CSV summary script.

In a test of the installed Orlino desktop app, build 0.0.4, on October 20, 2026, we selected Code Generation and asked for a local Python command-line tool. It produced a script using the standard library, two input files and category summaries. We checked the saved files and reran the script independently. All examples here are fictional.

Define the file before asking for code

The input had four required columns: item, category, quantity and unit_price. Quantities had to be nonnegative whole numbers. Prices had to be nonnegative decimal values with no more than two fractional digits. The output needed one row per category, alphabetically sorted, with totals shown to two decimals.

We also specified what should happen on failure. The script had to validate every row before touching the output file. An invalid value needed an English error with its row number and a nonzero exit status. A missing required header had to stop the run too.

item,category,quantity,unit_price
"Workshop, kit",Materials,2,3.25
Markers,Materials,3,1.10
Room,Venue,1,25.00

The first item contains a comma, so the CSV quotes the whole item name. Python's csv module documentation explains the reader and writer APIs, including opening files with newline="". The generated script used csv.DictReader rather than splitting the text on commas.

Check the summary against hand calculations

Category

Calculation

Expected total

Materials

2 × 3.25 + 3 × 1.10

9.80

Venue

1 × 25.00

25.00

The saved output matched both totals. In the second test, the input started with a UTF-8 byte order mark. It included a zero-quantity row, two Travel items at 0.10 each and an Admin item priced at zero. The output retained Admin,0.00 and returned Travel,0.20.

The script read prices into Decimal from strings. Python's Decimal documentation describes decimal representation and its precision settings. These small fixtures produced the expected exact totals; this test did not assess very large amounts or rounding policies for other kinds of data.

Test the path that must stop

We supplied five invalid files: one without the unit_price header, one with quantity 1.5, and three with a negative price, NaN or trailing text in a price. Every run exited with an error. An existing sentinel output file stayed byte-identical, and the input files stayed unchanged.

The app's first test harness reported two output mismatches because it compared CSV carriage-return line endings with plain line-feed text. Orlino corrected the comparison and reran it: 14 checks passed. Our independent check parsed the output as CSV and confirmed the field values. Keep that distinction when investigating a failed test: inspect the data and the comparison rule before changing the expected result.

A starting prompt for your own CSV

Use Code Generation to create a local Python CSV summary tool.
Input columns: [list exact headers].
Group by [column]. Calculate [formula].
Use only the Python standard library. Preserve input files.
Define valid numeric formats and reject invalid rows with row numbers.
Validate the full input before creating or overwriting output.
Save the script, two small fixtures, expected outputs and executed tests.
Report actual exit statuses and any checks you did not perform.
Use English throughout.

Start with a copy containing a few rows whose answers you can calculate yourself. Review the code, run the valid cases, then test the errors that matter for your data. Large files, unexpected encodings, duplicate headers and using the same path for input and output need separate checks before you rely on the tool for those conditions.

Try Orlino with a small synthetic CSV and an explicit output rule.

Product information and editorial note

This article describes the bounded workflow and examples shown above. It is not an independent benchmark or a guarantee that other inputs, models, or app versions will behave the same way. Check the app for current model availability and usage limits.

Published by Orlino Editorial. Read our editorial process.

Try your next task in Orlino.

Bring your notes, files, and questions to Orlino. Choose the app for your device.

Download Orlino

Keep reading

← All articles