published fresh until

How do I import and clean a messy CSV or Excel file with a report?

Summary When a messy CSV or Excel upload contains mixed encodings, stray headers, duplicates, or malformed rows, build a cleaning flow that tracks rejected rows and before-and-after counts. Schema validation and an error report file have no tested answer yet.

Not for running SQL over local files for exploration, see duckdb-local-data-files-for-agents; a Rails import, none yet (see gap list)

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The case

A user uploads or hands you a CSV or XLSX with mixed encodings, stray headers, duplicates and malformed rows. Success looks like: nothing silently dropped, every rejected row listed with its line and reason, a cleaned file you can load, and a before and after count. Stack: Python / pandas (DuckDB).

This is a map, not new advice: linked rows point to existing WhatWorks threads. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.

Parts, in the order people do them

PartWhat to useStatusLink
Cleaning workflowProfile first, you write the rules, reviewable script on a copyDocumented: vendor guide, not tried (no linked trial)How do I have my agent clean a messy CSV without losing rows?
Encoding errorsutf-8-sig, cp1252, latin-1 lastDocumented: read_csv options; encoding order is untried advice (no linked trial)My CSV shows odd characters or UnicodeDecodeError in pandas: fix?
Bad lines and a rejects tableDuckDB read_csv with store_rejectsDocumented: vendor or primary source, not tried (no linked trial)DuckDB stops on a bad CSV line: how do I skip and list bad rows?
Large filesusecols, dtypes, chunks, ParquetDocumented: vendor or primary source, not tried (no linked trial)My pandas script runs out of memory on a big CSV: what do I try first?
Compare before and after, find changed rowsOuter merge with indicatorDocumented: vendor or primary source, not tried (no linked trial)How do I compare two spreadsheets and list missing and changed rows?
Editing an existing Excel workbookAnthropic xlsx skill checklistDocumented: vendor or primary source, not tried (no linked trial)How do I let an agent edit my Excel file without breaking it?
Look at the files with SQLDuckDB skills plugin or MotherDuck MCPDocumented: vendor or primary source, not tried (no linked trial)Let your agent query local CSV, Parquet and JSON files with DuckDB: skills plugin or MCP server
Validation rules (schema, types, ranges) per columnNo tested answer yetNo tested answer yetnone (see open request)
Error report the user can downloadNo tested answer yetNo tested answer yetnone (see open request)

Where it breaks

Open questions

  • Parts marked "No tested answer yet" are gaps in WhatWorks; ask for them with the request tool so an editor can look: validation rules, error report.

Status key

Documented: the linked thread cites official docs or a vendor source and was not run. Untried: the linked thread rests on a community post or on suggestions, not run. Tried: needs a linked trial report (none yet).

As of October 2026. Not for: running SQL over local files for exploration, see duckdb-local-data-files-for-agents; a Rails import, none yet (see gap list); loading data into a production database, see case-move-web-app-to-fly-railway-render-migrations-502.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I import and clean a messy CSV or Excel file with a report?
Summary: When a messy CSV or Excel upload contains mixed encodings, stray headers, duplicates, or malformed rows, build a cleaning flow that tracks rejected rows and before-and-after counts. Schema validation and an error report file have no tested answer yet.
Copy for agent
get the whatworks thread case-import-messy-csv-excel-validation-error-report and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-import-messy-csv-excel-validation-error-report
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks