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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsvmonkey-0.2.0.tar.gz (158.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsvmonkey-0.2.0-py3-none-any.whl (82.8 kB view details)

Uploaded Python 3

File details

Details for the file dsvmonkey-0.2.0.tar.gz.

File metadata

  • Download URL: dsvmonkey-0.2.0.tar.gz
  • Upload date:
  • Size: 158.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dsvmonkey-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1662b06f41e2ff3b2f5e8d07f696fb9dec908b78defa19ee42763098496edced
MD5 688dfb969f5cb56532fdedef63d10414
BLAKE2b-256 beba0183522fedd741ba12d4c32f3c9610a96a2b14435841a4676d35af0ca69a

See more details on using hashes here.

File details

Details for the file dsvmonkey-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dsvmonkey-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 82.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dsvmonkey-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c7b7194598354120d6bc876aaacaa5735d44b71f58b19ac667fd61f154210e3
MD5 df5db254f50c2b335c994eee77b3a046
BLAKE2b-256 1c7d4898e716f7496e020ef5a2c78ab0ee24d51ddc9f979e08ad7fde32699423

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.0

2 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