# Cleaning Messy CSVs With A Rules-First Prompt

> Make it list the rules it will apply before it touches a single row.

- **Author:** [Mateo Gonzalez (@mateo_gonzalez)](https://www.promptabide.com/mateo_gonzalez)
- **Published:** 2026-06-04
- **Updated:** 2026-08-22
- **Tags:** `data`, `etl`, `pandas`, `data-quality`
- **Views:** 8955
- **Likes:** 615

## Prompt

```
Handing over a messy export and saying "clean this" gets you a cleaned file and no idea what it decided. Dates silently reinterpreted, a whole column dropped because it looked empty in the first 50 rows.

Two-step it:

"Here are the first 200 rows. Do not transform anything yet. List every data quality problem you can see and the rule you would apply for each. Flag any rule where the right choice is ambiguous."

Read the list, correct the two rules that are wrong, then:

"Apply those rules. Output the transformation script, not the transformed data, plus a count of rows affected per rule."

Getting the **script** rather than the data is the important part — it is reviewable, re-runnable, and works on the full 4M rows rather than the sample.
```

---

Canonical HTML: https://www.promptabide.com/bides/cleaning-csv-rules-first-mateo-gonzalez-2
Agent guide: https://www.promptabide.com/llms.txt · https://www.promptabide.com/agent-instructions.md
Sitemap: https://www.promptabide.com/sitemap.xml
