Csv cleaner

From Krusty84/SKILL.md-Inspector · View interactive version

Csv cleaner is an AI agent skill from the GitHub repository Krusty84/SKILL.md-Inspector. Clean and normalize messy CSV/TSV files - fix malformed rows, inconsistent headers, mixed encodings, stray delimiters, and duplicated records - and deliver a valid, verified file. Use when the user mentions a broken, messy, or malformed CSV, a file a spreadsheet tool refuses to open, or asks to dedu

How to use this skill

Skill file

CSV Cleaner

Repair a malformed delimited file into one that parses cleanly, without

silently losing data.

Core principle

Never destroy data silently. Every dropped row, merged duplicate, or

coerced value must be counted and reported to the user at the end.

Workflow

1. Diagnose before touching anything

file -i input.csv          # encoding
head -5 input.csv          # delimiter, header shape
wc -l input.csv            # row count baseline

Then attempt a strict parse (e.g. Python csv with strict=True) and record

every failure with its line number. Common findings:

| Symptom | Likely cause |

|---|---|

| Field count varies by row | unquoted delimiter inside a value |

| � replacement chars | wrong encoding assumption (try cp1252, latin-1) |

| Header repeats mid-file | concatenated exports |

| Rows of only commas | trailing padding from export tool |

2. Fix in this order

  1. Encoding → convert to UTF-8 first; everything downstream assumes it.
  2. Structural repairs → re-quote fields containing delimiters, remove repeated

header rows, drop fully-empty rows.

  1. Header normalization → trim whitespace, deduplicate column names

(name, name_2), only rename beyond that if the user asked.

  1. Value normalization → only what the user requested (date formats, casing,

whitespace). Do not "improve" values unprompted.

  1. Deduplication → only if requested. Ask which columns define identity if it

is ambiguous; exact-full-row duplicates may be merged without asking.

3. Verify — this step is not optional

Re-parse the output strictly. The job is done only when all of these hold:

If verification fails, fix and re-verify. Never hand over a file that did not

pass.

4. Report

Tell the user: what was wrong, what was changed, exact counts

(rows in / out / dropped / merged), and anything that needs their judgment.

Write the result to a new file — never overwrite the original.

Edge cases

delimiters per line across a sample; the one with a consistent count wins.

If neither is consistent, ask the user.

to convert to numbers.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.