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.



The key features are:

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, custom httpx clients, 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.

Project

Indices