Data & spreadsheets

Cleaning rules first

Never let a tool clean your data straight away. Make it propose numbered, reviewable rules, and make it show you what each rule would change.

Use this before any bulk edit of data you cannot easily undo.

The pattern

Copy this and replace everything in [SQUARE BRACKETS] with your own specifics.

Prompt template
Here is a sample of my data: [PASTE 15-20 REAL ROWS, including the ugliest ones you can find.]

Full dataset is [N] rows of [WHAT IT IS]. I need it clean enough to [THE ACTUAL PURPOSE].

Do not clean anything yet.

Propose a numbered list of cleaning rules. For each rule:
- What it does, precisely enough that two people would apply it the same way.
- How many rows in my sample it would change, and which ones.
- What it would destroy if my assumption is wrong.

Then list separately: anything that looks wrong but that you should NOT touch, and why.

Wait for me to approve or edit the rule list.

Why each part is there

Include the ugliest rows
Rules proposed from clean rows will fail on the dirty ones. The messy rows are the whole reason you are here — hiding them just defers the problem.
The actual purpose
Clean is relative. Data clean enough to count is not clean enough to average, and merging “Mumbai”/“Bombay” is right for a headcount and wrong for an audit trail.
Which rows it would change
Turns each rule into a preview. A rule that touches 14 of 20 sample rows is doing something much bigger than you probably intended.
What it would destroy
Cleaning is lossy. Making the loss explicit before you approve is the difference between a decision and an accident.
The do-not-touch list
Real signal often looks like dirt: duplicate names that are two real people, a negative value that is a genuine refund. Asking for this list protects the things worth keeping.

Before and after

The lazy version

Clean up this data and give it back to me tidy.

What goes wrong: It comes back tidy. Somewhere along the way twelve rows were merged, three dates were reinterpreted as US format, and a category was renamed — with no record of any of it, and no way to reverse it.

The pattern, filled in

Worked example
Here is a sample of my data: [20 rows of a club sign-up sheet — names in mixed case, "phone" column with and without +91, dates as both 03/04 and 3 Apr, two people with the same name, one row that is clearly a test entry.]

Full dataset is 340 rows of event sign-ups. I need it clean enough to send one WhatsApp message per person and count attendance by class.

Do not clean anything yet.

Propose a numbered list of cleaning rules. For each rule: what it does precisely, how many sample rows it changes and which, and what it would destroy if the assumption is wrong.

Then list separately: anything that looks wrong but that you should NOT touch, and why.

Wait for me to approve or edit the rule list.

What that buys you: Eight rules you can approve or reject one at a time — and a do-not-touch list that flags the two identical names as probably two real students, which is exactly the “duplicate” a one-shot clean would have deleted.

Now do it on your own work

Find genuinely messy real data (a sign-up sheet, exported marks, a downloaded CSV). Get the rule list, then REJECT at least one rule and say why. Apply the rest to a copy, never the original.

Check yourself — every box should be true

  • You worked on a copy, and the original is untouched.
  • You rejected or edited at least one proposed rule, with a reason you can state.
  • You checked the “would destroy” note on every rule you approved.
  • The do-not-touch list contains at least one item you agree with.

Then explain it back

One of the rules you approved was lossy — it threw information away. Which one, and why was the loss acceptable for your purpose but not in general?

Write two or three sentences in your own words. If you cannot, you copied a prompt rather than learning a pattern — which is the whole difference this library is trying to make.

Does this depend on which AI tool I use?

Tool-agnostic as a thinking pattern, but be careful with tools that execute code on an uploaded file: there the cleaning happens for real, and “propose rules first” is the only thing standing between you and an irreversible transformation. Always upload a copy.

Why it actually works

Every judgement call you just made — what counts as a duplicate, which dates mean what — is a decision that will show up later in whatever a model learns from this data.

Where data work actually starts

Prompting well is a skill you can pick up in a week. Understanding what is happening underneath is the 18-month curriculum — and it is what stays useful when the tools change.

FAQ

Why not just clean it and check afterwards?
Because after a bulk transform you no longer know what changed, so “checking” means re-deriving the original. Rules are reviewable in minutes; a transformed file is not.
What if the data is too big to sample?
A sample is enough to write the rules — pick rows deliberately, including the worst ones you can find, rather than the first twenty. Then apply the approved rules at full scale and count how many rows each one touched.

Next patterns

The Prompt Patterns Library is a separate, optional track — it does not change the 78-week curriculum or your roadmap. See what the curriculum actually covers →