Skip to main content

dsvmonkey

Detect, profile, normalize and repair delimiter-separated-values files.

CSV is a polite lie. Real files are tab-separated, pipe-separated, or semicolon-separated; start with decorative title rows; carry BOMs and mixed encodings; include ragged rows and quoted newlines. dsvmonkey reads them anyway, tells you what it found, and hands you a clean stream of rows.

Status

Alpha. API is not yet stable.

Install

pip install dsvmonkey

For development (editable install with test tooling):

pip install -e .[dev]
# or equivalently:
pip install -r requirements-dev.txt

Both requirements.txt and requirements-dev.txt are thin pointers to pyproject.toml — the single source of truth for dependency lists. Edit dependencies in pyproject.toml; the requirements files need no maintenance.

What it does

  • Detect encoding, delimiter, quote char, header row and line endings — each with a confidence score, runner-up alternatives and the reasoning behind the choice.
  • Normalize cells on read using cleanmonkey (BOMs, NBSPs, zero-width spaces, smart quotes, stray control chars).
  • Profile date columns via datemonkey.
  • Repair ragged rows, stray BOMs and inconsistent line endings.
  • Stream row-by-row; large files are fine.
  • Chain cleanly into pgmonkey (DB import), xlfilldown (Excel output) and typemonkey (type inference).

CLI

dsvmonkey inspect   file.csv                       # human-readable detection report
dsvmonkey normalize file.csv -o clean.csv          # strip BOM, fix ragged rows, normalize endings
dsvmonkey convert   file.csv -o out.jsonl --to jsonl

Run dsvmonkey --help or dsvmonkey <command> --help for the full list. Flags are command-specific:

  • inspect: -v/--verbose, --no-columns, --sample-rows, --excel-serial-min, --no-deep-scan, --clean-sample, --strict (exit 3 instead of 0 when the profile recommends human review — the unattended-pipeline gate).
  • normalize: --encoding, --line-ending lf|crlf|cr, --delimiter, --field-count, --no-clean, --no-deep-scan, --keep-empty-rows, --sanitize-formulas, --strict (same gate semantics as inspect --strict: profile first, exit 3 with no output written when detection isn't confident enough).
  • convert: --to {csv,tsv,jsonl}, --no-clean, --no-deep-scan, --keep-empty-rows, --sanitize-formulas (applies on every output format, including jsonl — JSONL output is commonly transformed back to CSV/Excel later, where formula payloads surviving as JSON string values become live formulas), --strict (gate as above).

Python API

import dsvmonkey

# Profile a file — encoding, delimiter, headers, etc.
profile = dsvmonkey.profile_file("file.csv")

# Stream cleaned rows as dicts
for row in dsvmonkey.read("file.csv"):
    ...

# Write a cleaned version
report = dsvmonkey.repair("messy.csv", "clean.csv")

# Convert to JSON Lines
dsvmonkey.to_jsonl("file.csv", "file.jsonl")

# Per-column profiling (date-format detection via datemonkey)
columns = dsvmonkey.profile_columns("file.csv")

Limitations

Some behaviours are deliberate design tradeoffs rather than bugs (e.g. mixed-encoding detection requires UTF-8 multi-byte evidence to avoid false-positives on cp1252 files; duplicate header names in dict mode warn-and-collapse rather than raise). See LIMITATIONS.md for the full list with rationale and escape hatches.

Using with AI assistants

SKILL.md at the repo root is a drop-in Claude Code / agent skill that teaches LLMs how to call dsvmonkey correctly — decision tree, failure modes it already handles, worked examples, and a "don't" list so agents stop reinventing broken CSV parsing. Copy it to ~/.claude/skills/ or include it in a project's AGENTS.md / CLAUDE.md for automatic discovery.

Contributing & review methodology

CONTRIBUTING.md documents the testing philosophy and the competitive multi-model review panel used to harden this package. The release decision is made against an explicit rubric (RELEASE_READINESS.md, scored by scripts/readiness.py); the panel-by-panel record lives in REVIEW_HISTORY.md and deliberate tradeoffs in LIMITATIONS.md.

License

MIT. See LICENSE.

Metadata

Release files for dsvmonkey 0.2.1

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

Source distribution (sdist)

Source distribution for dsvmonkey 0.2.1
File Size Uploaded Provenance
dsvmonkey-0.2.1.tar.gz 159.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 241.8 kB

Release files / dsvmonkey-0.2.1.tar.gz

Download URL dsvmonkey-0.2.1.tar.gz
Size 159.0 kB
Tags Source
SHA-256 checksum
How to use checksums
10d15908a58a9b2462372b05326cd1412ac0a72cbace7b14f9a97e41623e7495
BLAKE2b-256 checksum
How to use checksums
efaa731ee0682f8ffb0c3d6ecdbb4de168532857e69ab2f1f97dcd7a57b6177f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / dsvmonkey-0.2.1-py3-none-any.whl

Download URL dsvmonkey-0.2.1-py3-none-any.whl
Size 82.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dffcab000eb79800f63ca4ee4c8f3c7932086272ee90dd0de6049bd0c4ecf4d
BLAKE2b-256 checksum
How to use checksums
f9a6c844e56e5c11e52a881c2d4b233bfa10a90a98519c87eccef69cb296eeb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for dsvmonkey 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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