Skip to main content

cleanvc

PyPI License: MIT

A lightweight, zero-dependency Python tool and CLI to clean up messy CSV files.

Features

  • Header Normalization: Automatically converts column headers into clean snake_case identifiers (e.g., First Name (%) -> first_name_pct).
  • Whitespace Stripping: Strips extraneous leading and trailing spaces from values and headers.
  • Empty Row Removal: Automatically discards completely blank rows.
  • UTF-8 with BOM Support: Safely reads CSV files exported from Excel and other spreadsheet software (utf-8-sig).
  • CLI & Python API: Use as a command-line utility or import in your Python scripts.
  • Zero Dependencies: Powered exclusively by the Python standard library.

Installation

pip install cleanvc

Command-Line Usage (CLI)

Once installed, use cleanvc directly from your terminal:

# Clean a messy CSV (creates cleaned_messy.csv automatically)
cleanvc messy.csv

# Specify custom output destination
cleanvc messy.csv -o clean_data.csv

# Custom delimiter (e.g., semicolon)
cleanvc messy.csv -d ";" -o clean_data.csv

# Check version
cleanvc --version

You can also run it via Python module invocation:

python -m cleanvc messy.csv -o clean_data.csv

Python API Usage

Process a CSV File

from cleanvc import CSVCleaner

cleaner = CSVCleaner()

# Automatically saves as cleaned_messy_sales.csv
cleaner.process_file("messy_sales.csv")

# Or specify your own output path
cleaner.process_file("messy_sales.csv", "cleaned_sales.csv")

In-Memory Row Cleaning

from cleanvc import CSVCleaner

cleaner = CSVCleaner()
raw_data = [
    {" First Name (%) ": "  Alice  ", " Score ": " 95 "},
    {" First Name (%) ": "   ", " Score ": ""},  # Automatically dropped
    {" First Name (%) ": "  Bob  ", " Score ": " 80 "},
]

cleaned = cleaner.clean_rows(raw_data)
# [
#   {"first_name_pct": "Alice", "score": "95"},
#   {"first_name_pct": "Bob", "score": "80"}
# ]

Running Tests

Run the unit tests with Python's standard unittest runner:

python -m unittest discover -v tests

Publishing to PyPI

  1. Install build and upload tools:

    pip install --upgrade build twine
    
  2. Build distribution artifacts:

    python -m build
    

    This generates the wheel (.whl) and source distribution (.tar.gz) in dist/.

  3. Verify the build:

    twine check dist/*
    
  4. Upload to TestPyPI (Recommended first):

    twine upload --repository testpypi dist/*
    
  5. Publish to PyPI:

    twine upload dist/*
    

License

MIT License. See LICENSE for details.

Metadata

Release files for cleanvc 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cleanvc 0.1.0
File Size Uploaded
cleanvc-0.1.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cleanvc 0.1.0
File Interpreter ABI Platform
cleanvc-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / cleanvc-0.1.0.tar.gz

Download URL cleanvc-0.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f6b747dcedc5682f01daef98b4413b51faf55b13b8b5cadcf053f63347593dfd
BLAKE2b-256 checksum
How to use checksums
0ca47bbaadda57fd5414d3cce146420f41824558478713ad9f5134e9a6b485d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / cleanvc-0.1.0-py3-none-any.whl

Download URL cleanvc-0.1.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97d64fd4bb4bcf5482bb06317d285fe96bdcbcfb683bb3a331e3100867396efd
BLAKE2b-256 checksum
How to use checksums
731eea12c8784475eb65b70e89be59713864f10fa7f155be646565487532ee81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page