In the pack: ChatGPT, Claude & Gemini Prompts for Coding and Developers
Clean and Validate a Messy Data File With a Script
Prompt
Language and allowed libraries (e.g. Python with pandas, or the standard library only): {{LANGUAGE}}
File format and a sample of the first 20 rows, with personal data replaced by fake values: {{SAMPLE_ROWS}}
The target format (columns, types, allowed values): {{TARGET_SCHEMA}}
Known problems (mixed date formats, currency symbols, duplicates, encoding, blank rows): {{KNOWN_PROBLEMS}}
The script must:
1. Read with an explicit encoding and delimiter, and never guess silently.
2. Apply each cleaning rule as a named, separate step, with a comment on why.
3. Validate every row against the target schema, writing rejected rows to a separate file with the reason for each.
4. Report counts: rows read, cleaned, rejected per reason, and duplicates removed.
5. Be idempotent: running it on its own output changes nothing.
6. Take input and output paths as arguments, with no hard-coded paths.
After the script, list the assumptions you made about ambiguous values (for example, is 03/04 the 3rd of April or March 4th?) and how to change each one. Include three test rows that exercise the trickiest rules.
Customize this prompt
Fill in the variables below to personalize this prompt:
Model Settings
Recommended Models
Temperature
Max Tokens
Additional Notes
About this prompt
“Clean and Validate a Messy Data File With a Script” is a free prompt for ChatGPT in the Coding & Software category, 203 words long, added to The Prompt Index on October 28, 2026 by The Prompt Index. Copy it with the button above, paste it into ChatGPT or any other AI chat assistant, and send it.
It has 4 placeholders to fill in first:
{{LANGUAGE}}, {{SAMPLE_ROWS}}, {{TARGET_SCHEMA}}, {{KNOWN_PROBLEMS}}.
Use the “Customize this prompt” fields to personalise it before you copy.
Recommended models: ChatGPT, Claude, Gemini.
0 upvotes, sent to an AI tool 0 times, viewed 7 times.
Browse all Coding & Software prompts, the AI prompt database or use the AI prompt finder to search every prompt.