Workflow L3 · Workflows informational

Ask for the Cleaning Steps as a Reusable Script

What it is

A workflow move: once you've cleaned and analysed a dataset interactively, ask ChatGPT to consolidate every step into a single reusable script you can run on next month's file without redoing the conversation.

from one-off to repeatableExplore & clean interactivelyAsk for it as one scriptRe-run on next file
Capture the cleaning as a script so next month is one command, not one hour.

Why it works

Interactive analysis is great for figuring out what to do but terrible to repeat — the steps are scattered across a dozen turns. Consolidating them into one parameterised script captures the logic once, so recurring reports become a single command instead of a fresh chat every period.

When to use it

Any analysis you'll repeat on new data — weekly sales, monthly cohorts, recurring exports that arrive in the same shape.

When not to use it

Genuine one-off investigations you'll never rerun, where writing a clean script is wasted effort.

Prompt

We've cleaned and analysed this data across the conversation. Now consolidate every transformation into one Python script I can run on next period's file: parameterise the file path, keep the same cleaning and calculations, and comment each step so I can tweak it later.

Example

After a back-and-forth cleaning a messy sales export, you get a single monthly_report.py — next month you drop in the new file and run it in seconds.

Advanced version

Ask it to add lightweight input checks — assert expected columns exist and row counts look sane — so the script fails loudly if next month's file arrives in a different shape.

Common mistakes

  • Re-doing the whole interactive cleaning every period from scratch.
  • Getting a script with the file path hard-coded so it only works once.
  • No sanity checks, so a malformed input silently produces a wrong report.

Related