Skip to main content

csvbox

Print a CSV file as a clean box-drawn table in the terminal. One file, standard library only.

$ python csvbox.py examples/data.csv
┌───────┬─────┬──────────────────┐
│ Name  │ Age │ City             │
├───────┼─────┼──────────────────┤
│ Alice │ 30  │ Moscow           │
│ Bob   │ 25  │ Saint Petersburg │
└───────┴─────┴──────────────────┘

Install

Python 3.8 or newer.

pip install csvbox

This adds the csvbox command:

csvbox examples/data.csv

Or skip installing entirely and run it from the source tree:

python csvbox.py examples/data.csv

Usage

The table goes to stdout, so it can be piped or saved:

csvbox examples/data.csv > table.txt

How it behaves:

  • the first CSV row becomes the header, separated by a rule;
  • every column is as wide as its longest value;
  • short rows are padded with empty cells, long rows are cut and reported on stderr;
  • files are read as UTF-8, so Cyrillic and other non-ASCII text works;
  • a header-only file is drawn without the middle rule.

Errors

No tracebacks: one readable message and exit code 1.

Case Message
file does not exist Error: file not found: data.csv
file is empty Error: file is empty: data.csv
file is not UTF-8 Error: file is not valid UTF-8: data.csv
file cannot be read Error: cannot read file: data.csv

Running the script without a path prints the usual argparse usage hint. That is expected behaviour, not a converter error.

Limitations

  • BOM. CSV files saved by Excel as "CSV UTF-8" start with a byte order mark, and the first header keeps an invisible \ufeff. If you need those, change encoding="utf-8" to encoding="utf-8-sig" in read_csv.
  • | inside a cell is printed as is: this is a terminal table, not Markdown.
  • Box drawing on Windows. Output is Unicode. Redirecting to a file from a legacy console may need PYTHONIOENCODING=utf-8.

Development

pip install pytest
pytest

Layout:

csvbox.py              # all the code: read_csv, rule, row_line, to_table, main
tests/test_csvbox.py   # tests
examples/              # sample inputs

License

MIT — see LICENSE.

Metadata

Release files for csvbox 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 csvbox 0.1.0
File Size Uploaded Provenance Actions
csvbox-0.1.0.tar.gz 5.3 kB Without provenance Details for csvbox-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 9.9 kB

Release files / csvbox-0.1.0.tar.gz

Download URL csvbox-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a943de697491afaf43930b9cc19d1d026eaf9cbff3d657a56bbce04340efb6b4
BLAKE2b-256 checksum
How to use checksums
391c22ae2acc7f6810cbccfe93acc29d80d8040ace24d89c16c8e03ceaaf6414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0rc1

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

Download URL csvbox-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e308f43e5471c46bae5e65a5f5f787a34f0d28b7a4a50cf9ed5643fe8d494c0b
BLAKE2b-256 checksum
How to use checksums
ac3b38ac9e5ffd0b5262ec17b28f8310bf269776eccc61b1dc9f337133135f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0rc1

Security for csvbox 0.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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