clean-csv-python¶
Python client for the CleanCSV HTTP API: receive cleaned JSON or CSV, request suggested deduplication rules, and call the API from synchronous or asyncio code using httpx.
Documentation: https://clean-csv-py.readthedocs.io/en/latest/
Source code: https://github.com/user0706/clean-csv-py
CleanCSV (hosted API & product): https://www.clean-csv.app/
The key features are:
Typed — Dataclasses (
cleancsv.types.CleanConfig, nested options, responses) instead of untyped dict soup.Sync and async —
cleancsv.client.CleanCSVClientandcleancsv.client.AsyncCleanCSVClient; inject your ownhttpxclient when you need timeouts, proxies, or auth headers.Practical responses —
cleancsv.types.CleanResultwithparse_json()intocleancsv.types.CleanResponse;cleancsv.types.SuggestResponsefor rule suggestions.Explicit errors —
cleancsv.errors.CleanCSVErrorwith HTTP context;cleancsv.errors.RateLimitErroron 429 when the API exposes retry hints.
Requirements¶
Python 3.10+
httpx (declared as a dependency; installed with the package)
A reachable CleanCSV deployment (use the public origin or self-host); the default base URL is
cleancsv.DEFAULT_BASE_URL.
Installation¶
pip install clean-csv-python
For contributors and tests:
pip install -e ".[dev]"
Example¶
Synchronous — minimal clean + JSON parse:
from pathlib import Path
from cleancsv import CleanCSVClient, CleanConfig, DEFAULT_BASE_URL
with CleanCSVClient(DEFAULT_BASE_URL) as client:
result = client.clean(Path("data.csv"), config=CleanConfig(format="json"))
payload = result.parse_json()
print(payload.meta, len(payload.data))
Async — same idea with asyncio:
import asyncio
from cleancsv import AsyncCleanCSVClient, CleanConfig, DEFAULT_BASE_URL
async def main() -> None:
async with AsyncCleanCSVClient(DEFAULT_BASE_URL) as client:
r = await client.clean(b"id,name\n1,Ada\n", config=CleanConfig())
print(r.parse_json().meta)
asyncio.run(main())
Configuration from JSON — build cleancsv.types.CleanConfig with cleancsv.types.config_from_mapping() when you load options from a file.
Where to go next¶
Usage — base URLs, multipart vs raw body,
version, customhttpxclients, concurrency notes.Installation — virtualenvs, local doc builds, Read the Docs.
Clients — client methods and context managers.
Types and configuration — all config and response types.
Exceptions — error types.
The API reference is generated with Sphinx autodoc from package docstrings.
User guide