TaskbyTask.Practical AI guides for work
Codex · Practical walkthrough

Use Codex to build a small CSV helper you can check

The same booking export lands every Monday and needs the same tidy summary. A small helper can do it the same way each week, but it earns your trust on a tiny file you can count yourself first.

Task by Task14 min read + practice
A small teal handloom turns clearly attached ivory and mint threads into a woven panel with one preserved lime stripe.

What you'll make

a small local program (a “helper”) that summarises a CSV file, plus a JSON summary you have checked against counts you worked out yourself.

What you'll need

the Codex app on your computer (Codex is included in ChatGPT Free, Go, Plus, Pro, Business, Edu and Enterprise plans, though a work admin may control access), a practice folder in a Git repository, the practice CSV and definitions (ZIP) and about 30 minutes. Python, if it’s already installed, is enough. Don’t install anything you haven’t been cleared to install.

Example result.

records: 5
channel counts: email 2, phone 2, web 1
recorded-minute count: 4
missing-minute count: 1
known-minute subtotal: 25
full duration total: unresolved

1. Decide whether a helper is worth it, then write the rules

A one-off question about a CSV is quicker in a chat: ask ChatGPT what your spreadsheet is telling you instead. A helper is worth building when the same export arrives every week, when a rule must be applied the same way every time, or when the file is too large to paste.

Open enquiries.csv and definitions.txt before asking for any code. Write down three rules:

  • Reference IDs are text. 001 and 01 can be different enquiries. Treating them as numbers merges them.
  • Zero and blank are different. Zero minutes is a recorded value. A blank is missing.
  • A repeated ID is a question, not a row to drop. The helper should stop and flag it.

Then work out the answer for the practice file yourself.

Why this works: your own answer is the test. If you can’t count the small file by hand, you can’t tell whether the helper is right.

What you should see: three rules and a hand-worked summary like the example result.

2. Ask for a plan before any code

In a new Codex task on the practice folder, ask for a read-only plan first. For more on why this matters, see ask Codex for a plan before it changes your files.

Plan a small local helper for enquiries.csv using definitions.txt. Keep the CSV unchanged and treat reference IDs as text. Count records, and records by channel. Report the recorded-minute count, missing-minute count and known-minute subtotal, and leave the full total unresolved while any minutes are missing. Zero is a recorded, valid value. Stop and flag duplicate references and negative or non-numeric minutes rather than dropping rows. Propose the helper and output filenames and how to run and check them with the Python already on this computer, using only its built-in tools. No new packages, online services, account access, source edits or publishing. Keep this stage read-only and list any rule that is still unclear.

Why this works: the plan shows how Codex has understood your rules before it writes anything you need to review.

What you should see: proposed filenames (for example helper.py and summary.json), how it will read the file, and any questions. Answer the questions before going on.

3. Create and run the helper

Approve the plan, then ask for only the files it named.

Create the planned helper and run it on the practice CSV. Write only [helper file] and [summary file]. Refuse to overwrite an existing output or the input. Keep IDs as text, keep zero and missing values distinct, and follow the duplicate and invalid-value rules. Report the files created, the run result and the checks. Do not change definitions, install packages, connect to services, commit, push or deploy.

[helper file] and [summary file] are the names from the plan.

Why this works: naming the only files it may write keeps the job small enough to review, and refusing to overwrite protects the input.

What you should see: two new files and a short run report.

4. Check the code and the summary

Ask Codex to explain how the helper reads fields, treats IDs and tells a blank from a zero, then find those lines in the code. A proper CSV reader matters when a field contains a comma in quotes. Splitting each line at every comma is not the same thing.

Open summary.json and compare every value with your hand-worked answer. Confirm the CSV is unchanged: keep a copy from before the run, or compare a file fingerprint (a checksum) before and after. Run the helper again and check it refuses to overwrite the existing summary.

Why this works: the explanation tells you where to look, and your own answer tells you whether the code is right.

What you should see: a summary that matches yours, an unchanged CSV and a refusal on the second run.

Check the result

  • Counts by channel match your hand count.
  • The known subtotal and the full total are separate fields, and the full total is unresolved while a value is missing.
  • 001 and 01 are still different IDs in the output.
  • The CSV and definitions are unchanged.

The usual failure: the blank becomes a zero. The summary says “total minutes: 25” with no missing count, which looks complete and is wrong. Spot it when the summary has one total and no line for missing values.

The helper output fails this check: [input, expected and observed result]. Inspect the parsing and calculation rule that caused it and fix the helper, not the source or the expected answer. Keep the source and existing files unchanged. Rerun the base case, the zero and blank case, the text-ID case, the duplicate case and the overwrite check, and report the results and any remaining gaps.

[input, expected and observed result] is one line, such as “E005 blank; expected missing 1 and total unresolved; got total 25”.

Worked example: 25 known minutes is not the full total

Fictional example.

reference,channel,minutes
E001,email,12
E002,phone,8
E003,email,0
E004,web,5
E005,phone,

The first run reported:

records: 5 · total minutes: 25

After the repair prompt, Codex found that the helper converted every empty field to 0. The rerun gave the example result at the top of this page: four recorded values, one missing, known subtotal 25, full total unresolved.

  • The zero stayed. E003’s 0 is a real recorded value, so it counts towards the four recorded values. Only the blank is missing.
  • A second test separates arithmetic from coverage. In a separate practice copy, put 4 in E005. The full total becomes 29 with nothing missing. Restore the blank and the full total must go back to unresolved.
  • The fix was in the helper. The CSV and definitions didn’t change. If they had, that’s the failure part 2 teaches you to catch.

Try it

Task by Task.Explore the example

A subtotal is not the whole total

Toggle the fifth value between missing and the separate practice value. Zero is already a recorded value.

A subtotal is not the whole total4/5 values recorded. Known subtotal: 25 minutes. Full total unresolved.06.7213.44minutesE00112E0028E0030E0045E005?
E00112Recorded valueE0028Recorded valueE0030Recorded zeroE0045Recorded valueE005UnknownUnknown

4/5 values recorded. Known subtotal: 25 minutes. Full total unresolved.

Fictional example. Four recorded values total 25 minutes. Fill E005 with 4 in a practice copy and the total is 29; restore the blank and the full total is unresolved.

Task by Task · Illustrative example

Task kit for this job: Download (ZIP) · Reusable instructions

Go deeper

Test identifiers and duplicates on purpose

Make a second tiny file that contains only the awkward cases, and run the helper on it.

reference,channel,minutes
001,email,12
01,phone,8
001,email,12

The first two IDs are different text. The third repeats 001. Under this exercise’s rule, the helper must stop and flag the duplicate. It shouldn’t count three enquiries, and it shouldn’t quietly remove one and imply the question is settled. If your real data allows repeated IDs, define what makes a record unique before changing the helper.

Compare with a reference helper

A reference helper (Python) shows one way to do the job. It reads the practice CSV with Python’s built-in CSV reader, writes a new JSON file, refuses to overwrite an existing output, and writes an unresolved full total as null. Look at it after you’ve reviewed Codex’s version, not before, so you judge Codex’s code on its own. It’s a check, not a reason to skip your rules or your hand count.

Before you run it on next week's file

Review which files the task changed with part 2, then run the helper on a real export that you can still check by eye. Keep the practice file and your hand-worked answer, and rerun them whenever the helper changes. Only then decide what “finished” means for this helper.

Sources

Optional analytics

With your permission, Google Analytics uses cookies to measure visits and which guides people read. It stays off until you accept. Use Analytics choices in the footer to change your choice. Rejecting after accepting refreshes this page. Privacy details.