Clean a messy CSV step by step without losing data
Get a data quality diagnosis of your CSV and an ordered cleaning plan: types, duplicates, blanks, dates, inconsistent categories, code or formulas, and final validation checks. Designed for ChatGPT, Claude, Gemini and Microsoft Copilot. It includes 4 customizable variables and you can copy it for free in one click.
Intermediate · Text · Pending editorial review
Prompt
Act as a data analyst who specializes in data quality and preparation. You work reproducibly and never delete information without recording it.
Context:
- File description (source, approximate row count, columns): {{description}}
- Sample rows (header plus 10-20 rows, anonymized): {{sample}}
- Tool I will use to clean it: {{tool}}
- What the clean data will be used for: {{end_use}}
If the sample is not enough to understand a column, ask me before deciding on a rule.
Deliverables:
1. A quick profile per column: expected type, detected type, problem examples and estimated share of blanks in the sample.
2. A list of issues found: encoding and odd characters, extra whitespace, inconsistent capitalization, mixed date formats, decimal separators, exact and likely duplicates, impossible or outlier values, categories spelled several ways.
3. An ordered cleaning plan (order matters), with one clear rule per step and the reason for it.
4. Implementation in {{tool}}: commented code, or formulas and menu steps.
5. A missing-value strategy per column (leave, flag, impute with an explicit rule, or exclude) without inventing data.
6. A final data dictionary: normalized column name, type, description and allowed values.
7. Validation checks after cleaning (row counts before and after, control totals, uniqueness per key).
8. A change log so every step can be audited.
Constraints:
- Always work on a copy and keep the original file.
- Never drop rows silently: count and justify every exclusion.
- Mark any business rule I need to confirm as [FILL IN].
- If you detect personal data, recommend anonymizing it before sharing.
Format: tables for the profile and dictionary, a numbered list for the plan and code blocks.How to use it
Paste the header and a varied sample that includes problem rows, with no real personal data. Apply the plan step by step on a copy and review the final checks before using the data.
Usage example
File: CRM order export, 12,000 rows · Tool: Python with pandas · End use: monthly sales report by region.
Sample output
Issues found in the sample
customer: trailing spaces and variants ("ACME Inc. ", "Acme Inc").date: mixed formats (02/03/2026 and 2026-02-03) and one blank (1003).amount: thousands comma and quotes vs plain decimal; one negative (−30).state: codes, names and abbreviations mixed ("ca", "California ", "Tex.").- 1001 and 1002 look like the same order duplicated.
Implementation (pandas)
import pandas as pd
raw = pd.read_csv("orders_raw.csv", dtype=str, encoding="utf-8")
df = raw.copy() # never touch the original
df = df.apply(lambda s: s.str.strip())
df["customer_norm"] = (df["customer"].str.upper()
.str.replace(r"[.,]", "", regex=True)
.str.replace(r"\s+", " ", regex=True))
# [FILL IN] confirm 02/03/2026 means Feb 3 (US order)
df["date"] = pd.to_datetime(df["date"], format="mixed", errors="coerce")
df["amount"] = pd.to_numeric(df["amount"].str.replace(",", "", regex=False), errors="coerce")
df["status"] = df["status"].str.lower()
STATES = {"CA": "CA", "CALIFORNIA": "CA", "TEX": "TX", "TX": "TX"} # [FILL IN] full list
df["state"] = df["state"].str.upper().str.rstrip(".").map(STATES)
df["flag_missing_date"] = df["date"].isna()
df["flag_negative"] = df["amount"] < 0 # [FILL IN] refund or error?
df["flag_likely_dupe"] = df.duplicated(["customer_norm", "date", "amount"])
assert len(df) == len(raw), "no rows dropped silently"
Doubtful rows are flagged, not deleted; every later exclusion is counted in the change log. …
Key facts
- Category
- Data management · Data cleaning
- Output type
- Text
- Level
- Intermediate
- Designed for
- ChatGPT, Claude, Gemini and Microsoft Copilot
- Verified in
- Pending editorial verification
- Variables
- File description, Sample rows, Tool and End use of the data
- Language
- English
- Price
- Free, no sign-up
- Updated
- Nov 7, 2026
Frequently asked questions
Can I paste the whole file?
For large files, the header and a representative sample are enough. The prompt produces rules and code that you then run on the full file in your tool.
Why does the order of steps matter?
For example, if you remove duplicates before normalizing whitespace and capitalization, you will miss duplicates that differ only in formatting.
Does it fill in missing values?
It only proposes strategies with an explicit rule and asks you to confirm them. It never invents values to fill gaps.
What is this prompt for?
Get a data quality diagnosis of your CSV and an ordered cleaning plan: types, duplicates, blanks, dates, inconsistent categories, code or formulas, and final validation checks.
Which AI tools does it work with?
It is designed for ChatGPT, Claude, Gemini and Microsoft Copilot. We have not verified it in these tools yet, so results may vary between them.
How do I customize the prompt?
Click “Customize” and fill in the variables (File description, Sample rows, Tool and End use of the data). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.
Do I need experience to use it?
It is intermediate: it helps to know the topic so you can provide good context and review the result critically.
Is this prompt free?
Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.
Can I trust the AI output?
Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.