datacleaner-lite
Utilities for inspecting, cleaning and streaming CSV datasets with a small CLI and a simple Python API.
Features
- Detect CSV delimiter and encoding (gzip + BOM aware)
- Normalize column names
- Remove duplicate rows and trim padding
- Stream large files without loading everything into memory
- CLI and programmatic API
Installation
Install from PyPI:
pip install datacleaner-lite
Or install from source:
pip install -e .
CLI
The package exposes a datacleaner CLI entry point.
Basic usage:
# Inspect a CSV (detect delimiter, encoding, basic metrics)
datacleaner inspect input.csv
# Clean a CSV, write to output (removes duplicates and trims whitespace)
datacleaner clean input.csv -o cleaned.csv
# Show help
datacleaner --help
Options (examples):
inspect <path>— Prints detected delimiter, total rows/cols and sampleclean <path> -o <out>— Streams cleaned CSV to<out>(defaults to stdout if not provided)
Use datacleaner --help for a full list of flags and options.
Python API
Import the package and call the high-level helpers:
import datacleaner as dc
# Inspect a file (returns a dict with metrics)
metrics = dc.inspect_csv("data.csv")
print(metrics)
# datacleaner-lite
[](https://pypi.org/project/datacleaner-lite/)
[](https://github.com/sergiduran2011-droid/datacleaner-lite/actions)
[](https://pypi.org/project/datacleaner-lite/)
[](https://opensource.org/licenses/MIT)
Utilities to inspect, clean and stream CSV datasets. Provides a small CLI
(`datacleaner`) and an ergonomic Python API suitable for pipelines and
batch processing.
---
## Table of contents
- Quickstart
- CLI examples
- Python API
- Development
- Publishing
- Contributing & Support
---
## Quickstart
Install from PyPI:
```bash
pip install datacleaner-lite
Inspect a CSV:
datacleaner inspect data.csv
Clean and write output (supports .gz input/output transparently):
datacleaner clean data.csv -o cleaned.csv
Or use programmatically:
import datacleaner as dc
metrics = dc.inspect_csv("data.csv")
print(dc.generate_report(metrics))
dc.clean_file("data.csv", output_path="cleaned.csv")
CLI
Usage: datacleaner <command> [options]
Common commands:
inspect <path>— detects delimiter, encoding, counts rows/cols and shows a small sampleclean <path> -o <out>— cleans rows (trim, dedupe) and writes CSV toout(or stdout)
Examples:
# Inspect gzipped CSV with BOM
datacleaner inspect data.csv.gz
# Clean, remove duplicate rows, and compress output
datacleaner clean input.csv -o output.csv.gz
# Clean and stream to stdout (pipe into another tool)
datacleaner clean large.csv | gzip > clean.gz
Options you may find useful (CLI flags):
-o, --output: output path (if omitted prints to stdout)--deduplicate/--no-deduplicate: enable/disable deduplication--delimiter: force delimiter detection override (e.g.,or;)--encoding: force input encoding (use with care; default tries detection)
Run datacleaner <command> --help for per-command options.
Python API
High-level functions (short API reference):
inspect_csv(path: str | Path) -> dict— Returns metrics:total_rows,total_cols,sample_rows,delimiter,encoding.clean_file(in_path: str | Path, output_path: Optional[str|Path]=None, deduplicate: bool=True) -> Optional[Path]— Streams cleaned CSV tooutput_path(or stdout) and returns the output path when given.clean_column_name(name: str) -> str— Normalizes a single column name (strip, lowercase, remove punctuation).clean_column_names(names: Iterable[str]) -> List[str]— Appliesclean_column_nameto a sequence.detect_delimiter(path: str | Path) -> str— Heuristic delimiter detection with fallback.generate_report(metrics: dict) -> str— Human-readable report string frominspect_csvmetrics.
Example (detailed):
from pathlib import Path
import datacleaner as dc
in_file = Path("data.csv.gz")
metrics = dc.inspect_csv(in_file)
print(dc.generate_report(metrics))
out = Path("cleaned.csv.gz")
dc.clean_file(in_file, output_path=out)
print("Wrote:", out)
Notes:
clean_filewill preserve gzip compression if the output filename ends with.gz.- Encoding detection attempts to handle UTF-8 BOM and common encodings; use
--encodingorencoding=parameter to override when necessary.
Development
Run tests and linters locally:
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pre-commit install
pre-commit run --all-files
pytest -q
Formatting / style:
black .isort --profile black .
Publishing (PyPI) — OIDC (recommended)
This repository includes .github/workflows/publish.yml which builds with python -m build and uses the pypa/gh-action-pypi-publish action. It is configured to request id-token: write so the job can authenticate to PyPI using GitHub's OIDC provider and a Trusted Publisher on PyPI.
Steps to enable Trusted Publisher on PyPI:
- Go to https://pypi.org/manage/account/ and under API tokens / Trusted publishers follow the instructions to register this GitHub repository or organization as a trusted publisher.
- Ensure the workflow has
permissions: id-token: write(already present in the workflow file). - Create a test release on GitHub and use the manual Run workflow button (workflow_dispatch) to trigger publish once configured.
If you prefer using a classic API token (less recommended), create a PYPI_API_TOKEN secret in GitHub and switch the workflow to use it instead.
Contributing & Support
Contributions, bug reports and PRs are welcome. Open an issue with a minimal repro if you find a bug.
For questions or maintenance contact: Sergi Durán sergiduran2011@gmail.com
Please follow the contributor checklist in CONTRIBUTING.md if you add features.
License
MIT — see LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datacleaner_lite-0.2.1.tar.gz.
File metadata
- Download URL: datacleaner_lite-0.2.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d24bc61d2e8edb1cb00c71104cabd7b839987b8e78c2a05cb32667fc04729348
|
|
| MD5 |
b0c534be521ca9d53c7972b672388343
|
|
| BLAKE2b-256 |
ed49a8718b49aac1f10f6412cec01ca32741cecab90cbb173fa782923bac5df1
|
Provenance
The following attestation bundles were made for datacleaner_lite-0.2.1.tar.gz:
Publisher:
publish.yml on sergiduran2011-droid/datacleaner-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datacleaner_lite-0.2.1.tar.gz -
Subject digest:
d24bc61d2e8edb1cb00c71104cabd7b839987b8e78c2a05cb32667fc04729348 - Sigstore transparency entry: 2475161335
- Sigstore integration time:
-
Permalink:
sergiduran2011-droid/datacleaner-lite@a2aacecaf0df26d7882a4ca929d37ae371cf9e61 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sergiduran2011-droid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a2aacecaf0df26d7882a4ca929d37ae371cf9e61 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file datacleaner_lite-0.2.1-py3-none-any.whl.
File metadata
- Download URL: datacleaner_lite-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2afd517b3637100fea005dacda2bde59225430a809d8a5c338742264f57f7c83
|
|
| MD5 |
e7429dbe02944facbeb50085596c7771
|
|
| BLAKE2b-256 |
bd9e972fee9dbc295e52c995caee96e1f5323e59b7f3cb4869255531423598ab
|
Provenance
The following attestation bundles were made for datacleaner_lite-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on sergiduran2011-droid/datacleaner-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datacleaner_lite-0.2.1-py3-none-any.whl -
Subject digest:
2afd517b3637100fea005dacda2bde59225430a809d8a5c338742264f57f7c83 - Sigstore transparency entry: 2475161364
- Sigstore integration time:
-
Permalink:
sergiduran2011-droid/datacleaner-lite@a2aacecaf0df26d7882a4ca929d37ae371cf9e61 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sergiduran2011-droid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a2aacecaf0df26d7882a4ca929d37ae371cf9e61 -
Trigger Event:
workflow_dispatch
-
Statement type: