Install
consolepip install columncheck
Use
consolecolumncheck data.csv # structure only
columncheck data.csv --header a,b,c # ... and the columns it must have
columncheck data.csv --sniff # guess , ; tab or | first
columncheck data.tsv --delimiter $'\t'
columncheck data.csv --allow-ragged # field counts may vary
columncheck data.csv --json # for a dashboard, exit 1 on problems
pythonfrom columncheck import lint_csv, sniff_delimiter
problems = lint_csv(open("data.csv", "rb").read(), expected_header=["id", "total"])
for problem in problems:
print(problem) # line 418: 4 field(s), header has 5 (ragged-row)
Checks
| code | what it means |
|---|---|
bom | the file starts with a byte order mark; the first column is \ufeffname |
nul-byte | a NUL byte, which most parsers choke on later |
empty-file | no header row at all |
empty-header | the header row is empty, or a column has no name |
padded-header | " a " — invisible in a spreadsheet, painful in SQL |
duplicate-header | the same name twice; DictReader silently keeps the last |
ragged-row | a row whose field count differs from the header |
missing-column / extra-column | the file is not what you expected |
encoding | the bytes are not valid in the encoding you asked for |
malformed | the CSV itself is broken |
Quoted fields containing commas or newlines are handled properly, and row numbers stay correct across a multi-line quoted field.
Limits
- Structure only: it does not check types, date formats or value ranges.
- It reads the whole file into memory once; that is fine for the sizes that fit in a
spreadsheet and wrong for a 30 GB dump — use a streaming validator there.
sniff_delimiterlooks at the first 50 rows and the four candidates, ; \t |.
Development
consolepython -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest
The suite covers every line of the package (pytest --cov --cov-branch), and the examples in the docstrings run as tests through --doctest-modules.
License
MIT.
Other libraries here
One problem each, standard library only, no runtime dependencies.
- argrepair — turn a bad tool call into a message the model can act on
- backoff-headers — turn a rate-limit header into the exact time to wait
- dir-digest — one hash for a directory tree, identical on every OS
- docanchor — catch every broken heading anchor in your docs
- envfile-diff — diff two .env files without printing the secrets
- fsync-replace — replace a file so a crash cannot leave it half-written
- header-date — HTTP dates parsed strictly, formatted correctly
- junit-merge — merge JUnit XML from every job into one honest report
- npm-semver — npm semver ranges, parsed the way npm parses them
- outputcap — keep a huge tool result out of the context window
- parse-size — byte sizes in and out, MB and MiB never confused
- path-containment — keep untrusted paths inside their directory
- redactscope — stop secrets in tool results before they reach the model
- runbudget — a per-run cost cap that warns before it stops
- testflakes — rank your flaky tests from the history you already have
- tool-loop-guard — catch an agent repeating itself while it is still cheap
- toolcall-ledger — a hash-chained record of every tool call
- toolcircuit — stop retrying a tool that is down
- toolquota — client-side rate limits your agent loop can wait on
- wheeldeps — read a wheel's dependencies offline, markers included
- zip-deterministic — byte-identical archives, build after build