CSV clean and dedupe with a change log
Detects encoding and delimiter, normalizes width, spaces, dates and phone numbers, and finds duplicate candidates. Writes a cleaned copy plus a change log; the input is never modified.
What it does
Cleans CSV exports (customer lists, data from legacy systems) without touching the original file.
- Detects the encoding (UTF-8, UTF-8 with BOM, Shift_JIS/CP932, EUC-JP) and the delimiter (comma, tab, semicolon, pipe)
- Profiles each column: empty cells, value kinds, cells with full-width ASCII or half-width katakana, edge spaces, ragged rows
- Normalizes width (full-width ASCII to half-width, half-width katakana to full-width, ideographic space to a normal space) and trims spaces, while keeping symbols such as circled digits
- Unifies dates to
YYYY-MM-DD, including2024/1/5,20240105, Japanese year-month-day notation and Japanese era dates such asR6.1.5 - Unifies phone number separators and
+81(choose digits only, hyphenated, or+81format) - Finds duplicates: exact rows, an exact business key (email, customer ID), and fuzzy matches on names that ignore legal-entity suffixes
- Logs every changed cell in
changes.csv(row, column, before, after, rule)
How to use
python scripts/csv_clean.py profile input.csv
python scripts/csv_clean.py clean input.csv --out-dir cleaned/ --key "email" --fuzzy-key "company"
The agent explains the profile first, confirms the date and phone columns and duplicate keys with you, then cleans. Duplicate candidates are never removed silently; you review them together.
Requirements
- Python 3 (standard library only)
Caveats
- The input file is only read, never overwritten or deleted. Existing output files are not replaced without
--force. - Output defaults to UTF-8 with BOM so Excel opens it correctly. Use
--out-encoding cp932for Shift_JIS; characters that Shift_JIS cannot hold cause an error. - Dates like
01/02/2024whose day/month order is unknown are left unchanged unless you specify the order. - Fuzzy matches are candidates only and may include branch offices. Above 5,000 rows, raise the limit or use an exact key.
How to install
- Unzip the downloaded file (it contains a
csv-clean-and-dedupe/folder withSKILL.md). - Copy the whole folder into your agent's skills folder.
- Claude:
~/.claude/skills/(per project:.claude/skills/) - Hermes Agent:
~/.hermes/skills/ - Codex:
~/.agents/skills// Cursor:~/.cursor/skills/ - Claude app (claude.ai): upload the ZIP in Customize → Skills
- Claude:
- Restart the agent and check that the skill appears in its skill list.
Seller
AI Skill Market (official)
44 published skills