Skip to main content

data-cleaner-agent

Clean a messy CSV with an agentic workflow. An LLM decides which cleaning steps the data needs, and tested Python functions do the actual work. The model plans the cleanup, it never touches your data values, so nothing gets hallucinated or silently rewritten.

Works offline out of the box (no API key). Can be driven by an LLM, and other AI agents can call it as an MCP tool.

Before / after

Full Name , Country, Signup Date, Amount Paid          full_name    country  signup_date  amount_paid
 Alice  ,Netherlands,2023-01-05,"€1.200,50"                Alice  Netherlands   2023-01-05       1200.5
Bob,nederland,05/01/2023,"$900"              ─────▶          Bob  Netherlands   2023-01-05        900.0
 Alice  ,NL,2023-01-05,"€1.200,50"                         Carol      Germany   2023-02-10       1000.0
Carol , Germany ,2023-02-10,1000                             Dan      Belgium   2023-03-01        750.0
Dan,belgie,2023/03/01,"€ 750,00"

In one pass it fixed the headers, trimmed whitespace, parsed three different date formats to ISO, turned €1.200,50 / $900 / € 750,00 into numbers, standardized the country names, and dropped the duplicate Alice row.

Install & run

pip install agentic-csv-cleaner

clean-csv messy.csv cleaned.csv       # clean a file
clean-csv messy.csv                   # or just print the result

No API key needed. The default planner is a set of offline heuristics.

The idea

An "agentic workflow" is just software with a few parts:

   look at the data   ->   planner picks the steps   ->   run the steps   ->   report
                           (rules, or an LLM)             (tested code)

The decision that makes it safe to trust:

The planner decides which tool runs on which column. The tools do the transformation. A language model is good at judgment ("this column looks like money") and bad at being a reliable calculator. So the LLM only ever picks operations from a fixed set. It never reads a value and writes back a "cleaned" one, which is where LLM data-cleaning usually goes wrong.

Two planners, one loop

Planner What it is Needs
RuleBasedPlanner Offline heuristics from a quick data profile. The default. nothing
LLMPlanner Sends the profile + tool list to an LLM, gets back a JSON plan. pip install "agentic-csv-cleaner[llm]" + ANTHROPIC_API_KEY

Both return the same list of steps, so the loop is identical. You swap the brain, not the plumbing.

Use it from other code or agents

from cleaner.api import clean_csv_text

result = clean_csv_text(open("messy.csv").read())
print(result["cleaned_csv"])
print(result["steps"])

As an MCP tool

Other AI agents (Claude Desktop, or any MCP client) can call the cleaner as a tool, so they can clean a CSV properly instead of reformatting it token by token in the prompt:

pip install "agentic-csv-cleaner[mcp]"
python -m cleaner.mcp_server

This exposes one tool, clean_csv, that takes CSV text and returns the cleaned CSV plus the steps.

What's in the box

cleaner/tools.py holds the transformations: snake_case_headers, strip_whitespace, coerce_numeric, standardize_dates, standardize_categorical, drop_duplicate_rows.

Take standardize_dates. 2023-01-05 (year first, month in the middle) and 05/01/2023 (day first) need opposite parsing rules, and one global setting corrupts one or the other, so the tool decides per value. Mixed dates are genuinely ambiguous, and this handles them explicitly instead of guessing.

Tests

python -m unittest discover -s tests

License

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentic_csv_cleaner-0.1.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentic_csv_cleaner-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file agentic_csv_cleaner-0.1.1.tar.gz.

File metadata

  • Download URL: agentic_csv_cleaner-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for agentic_csv_cleaner-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d986d8c635120c9ec2d4865e2cbc9b8412273fb904a4f2cb8a35ea82e94123ac
MD5 170a6e72ff1d3851c4e6208aacf27a67
BLAKE2b-256 f0aafdf4b61f38b9a80435dfa57c06b64960e960d94b3050621252d546e491d7

See more details on using hashes here.

File details

Details for the file agentic_csv_cleaner-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_csv_cleaner-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8492bc0a2f679fbc21a923f2f9dc994b611450e62cbbf5e7ba4bfce6740a81d6
MD5 4047a14c65d99080fb03830336d6bfd9
BLAKE2b-256 d957a655bb3082dbfaca380a7ee007865eba0f473a9a26a710b780fa841542dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page