Clean a CSV File With Python
Data cleaning scripts often drop rows without telling you. This prompt asks for a script that reports every change, so nothing disappears quietly.
Works with Claude, ChatGPT and Gemini3 fields
Write a Python script that cleans a CSV file with these columns and sample rows: ``` name,email,signup_date,amount Ana,[email protected],2024-03-01,10.5 bob ,[email protected],03/02/2024,"1,200" ``` Fixes: trim spaces, lowercase emails, dates to YYYY-MM-DD, amounts to numbers, drop exact duplicates Libraries: Python standard library only Requirements: - Read input.csv and write clean.csv; never overwrite the input. - Print a report: how many rows were changed or dropped by each rule, and list rows that could not be parsed instead of dropping them silently. - Keep the code short and commented.
Everything you type stays in your browser. Remove passwords, keys and personal data before pasting anything into an AI tool.
Why this prompt is written this way
- Never overwrite input. You can always compare before and after, or start over.
- A change report. Counts per rule show at once if a rule did more than you expected.
- No silent drops. Unparseable rows are listed so you can fix them by hand.
Example answer
Illustrative and shortened, to show the shape of a good answer. Real answers vary by model.
rows read: 1,000 emails lowercased: 212 dates converted: 340 duplicates dropped: 7 unparseable rows: 2 (lines 88, 413)
Tips
- Give real sample rows, including the messy ones.
- Open clean.csv in a spreadsheet and spot-check before using it.
How to use it
- Replace the example values with your own. The prompt on the right updates as you type.
- Press Copy prompt and paste it into any AI chat, or open it straight in Claude or ChatGPT.
- Save it as prompt.md if you want to reuse it.