Build/Build & digital tools

Create a data-cleaning script from messy examples

Define cleanup rules and edge cases before generating a reversible script.

Make it mine

WHAT YOU’LL MAKETransformation specification
WHAT TO BRINGSample records · Desired format
SEE THE WHOLE TASK

From these inputs to this result.

An authored, illustrative sample using fictional or supplied example data. This reference is not a recorded AI run; your tool’s answer will vary.

See the exact sample inputs

Sample records

row_id,name,email 1, Avery Chen ,AVERY@example.test 2,Avery Chen,avery@example.test 3,Morgan Reed, 4, Casey Park,Casey@example.test

Desired format

CSV columns row_id,name,email. Trim surrounding whitespace. Lowercase email. Deduplicate nonblank email case-insensitively, keeping the first row. Never discard a row just because email is blank. Keep row IDs. For this sample, expect 3 output rows and 1 duplicate removed. Generate a Python standard-library script that writes a NEW output file, refuses to overwrite an existing file, reports input/output/duplicate/blank-email counts, and shows how to run it. Never modify the source file.

REFERENCE RESULT / cleaned-records.csv
row idnameemail
1Avery Chenavery@example.test
3Morgan Reed—
4Casey Parkcasey@example.test

Ready to use your own material? Make this yours →

WORKING CODE YOU CAN TRY

Run the sample yourself.

This small Python script performs the cleanup described above. It writes a new file, keeps blank-email rows, and refuses to overwrite existing files. It was checked against the sample and awkward CSV values.

python clean-records.py sample-records.csv my-cleaned-records.csv

Requires Python 3. Run in the folder containing the downloads. This checks this specific cleanup rule; it does not decide whether two people are the same person.

FROM IDEA TO SOMETHING REAL

Write the cleanup rules before the script.

  1. 01

    Provide a small representative sample with messy records and the exact output format you want.

  2. 02

    Resolve ambiguous dates, empty values, duplicates, and identifiers before generating the transformation.

  3. 03

    Run the script on a copy first, then compare row counts, changed fields, and rejected records.

Your starting prompt

Replace the bracketed details or make it yours using the form.

Help me design a reversible data-cleaning script.

REPRESENTATIVE SAMPLE RECORDS
[Add sample records]
DESIRED OUTPUT FORMAT
[Add desired format]

First propose explicit transformation rules with before-and-after examples. Flag ambiguities around dates, missing values, duplicate definitions, and identifiers with leading zeros. Ask me to resolve material ambiguities before destructive transformations. Generate a script that reads an input copy, writes a separate output, and reports changed, unchanged, and rejected records. Include a dry-run option and meaningful checks for row counts and edge cases. State the runtime requirements and distinguish code you have actually run from code that remains untested.
MAKE A GOOD RESULT BETTER

Give it a second look.

  • The original input is preserved and ambiguous records are reported.
  • Identifiers keep meaningful leading zeros, and totals or row counts reconcile.
A FOLLOW-UP WORTH TRYING

“Add a dry-run mode that prints proposed changes without writing output. Include one test each for a duplicate, an empty field, and an ambiguous date.”

The capability to look for

A coding assistant or artifact environment; the result still needs to run and be checked.

Find a tool for the job

How these ideas and prompts are made

Did you get a result you could use?