Printable
CLI and functions help for printing tabular data.
Install
pip3 install printable
Rendering Engines
Two engines render tables: python (pure Python) and column (a ctypes binding of the compiled util-linux column command). By default (auto), the column engine is used when no --grid is set, and falls back to the python engine if the shared library is missing; grid styles always use the python engine. Select explicitly with -e python|column|auto.
Width calculation uses the native library when available and falls back to pure Python otherwise. 5000×6 mixed zh-en rows (make bench):
| engine | width calc | median (ms) | speedup (vs original) | speedup (vs now) |
|---|---|---|---|---|
| python (original) | pure Python | 322 | 1.0x | |
| python (now) | pure Python | 75 | 4.3x | 1.0x |
| python + C width | native C | 27 | 11.9x | 2.8x |
| column | native C | 17 | 18.9x | 4.4x |
The original row is the pre-optimization implementation (git a5ce114): per-cell wcswidth, per-character control normalization, and duplicated row formatting. Optimizations: batched width calculation via the native library, flattened single-call batch, and regex-based normalization.
Usage Example
from printable import readable
print(readable(list_of_dict, grid='full'))
$ printable -t csv -f samples/sample.csv
symbol desp last change changeper turnover changesign lastupdate
HSI 恆指 26623 -468 1.73% 802億 - 2018/10/04 16:09
HSCEI 國指 10547 -239 2.21% 257億 - 2018/10/04 16:08
000001.SH 上證指數 2821 29 1.06% 1254億 + 2018/09/28 15:10
000300.SH 滬深 300 3438 35 1.04% 949億 + 2018/09/28 15:10
USDHKD 港匯 7.8337 -0.0037 -0.0472% -
$ printable -t csv -f samples/sample.csv --grid inner
symbol │ desp │ last │ change │ changeper │ turnover │ changesign │ lastupdate
───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────
HSI │ 恆指 │ 26623 │ -468 │ 1.73% │ 802億 │ - │ 2018/10/04 16:09
───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────
HSCEI │ 國指 │ 10547 │ -239 │ 2.21% │ 257億 │ - │ 2018/10/04 16:08
───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────
000001.SH │ 上證指數 │ 2821 │ 29 │ 1.06% │ 1254億 │ + │ 2018/09/28 15:10
───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────
000300.SH │ 滬深 300 │ 3438 │ 35 │ 1.04% │ 949億 │ + │ 2018/09/28 15:10
───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────
USDHKD │ 港匯 │ 7.8337 │ -0.0037 │ -0.0472% │ │ - │
$ printable -t csv -f samples/sample.csv --grid full
┌───────────┬──────────┬────────┬─────────┬───────────┬──────────┬────────────┬──────────────────┐
│ symbol │ desp │ last │ change │ changeper │ turnover │ changesign │ lastupdate │
├───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────┤
│ HSI │ 恆指 │ 26623 │ -468 │ 1.73% │ 802億 │ - │ 2018/10/04 16:09 │
├───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────┤
│ HSCEI │ 國指 │ 10547 │ -239 │ 2.21% │ 257億 │ - │ 2018/10/04 16:08 │
├───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────┤
│ 000001.SH │ 上證指數 │ 2821 │ 29 │ 1.06% │ 1254億 │ + │ 2018/09/28 15:10 │
├───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────┤
│ 000300.SH │ 滬深 300 │ 3438 │ 35 │ 1.04% │ 949億 │ + │ 2018/09/28 15:10 │
├───────────┼──────────┼────────┼─────────┼───────────┼──────────┼────────────┼──────────────────┤
│ USDHKD │ 港匯 │ 7.8337 │ -0.0037 │ -0.0472% │ │ - │ │
└───────────┴──────────┴────────┴─────────┴───────────┴──────────┴────────────┴──────────────────┘
$ printable -t csv -f samples/sample.csv --grid markdown
| symbol | desp | last | change | changeper | turnover | changesign | lastupdate |
|-----------|----------|--------|---------|-----------|----------|------------|------------------|
| HSI | 恆指 | 26623 | -468 | 1.73% | 802億 | - | 2018/10/04 16:09 |
| HSCEI | 國指 | 10547 | -239 | 2.21% | 257億 | - | 2018/10/04 16:08 |
| 000001.SH | 上證指數 | 2821 | 29 | 1.06% | 1254億 | + | 2018/09/28 15:10 |
| 000300.SH | 滬深 300 | 3438 | 35 | 1.04% | 949億 | + | 2018/09/28 15:10 |
| USDHKD | 港匯 | 7.8337 | -0.0037 | -0.0472% | | - | |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file printable-0.4.4.tar.gz.
File metadata
- Download URL: printable-0.4.4.tar.gz
- Upload date:
- Size: 429.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edd3b8a38753e6d807f26db892d8186782088998b87bb7031f7760319c7002be
|
|
| MD5 |
8d7ec3f978199bc23e7a816bec07d1e4
|
|
| BLAKE2b-256 |
2f4b30260f69265d0861206b06a7324b7388516f8f0adf476a7b3bd3b7f34af8
|
File details
Details for the file printable-0.4.4-py3-none-any.whl.
File metadata
- Download URL: printable-0.4.4-py3-none-any.whl
- Upload date:
- Size: 427.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5027d132b8e831fd2d74c5cfe6f7a15555de81037d85fe7a498cc6c7f949879f
|
|
| MD5 |
0b61a6bfebd63bbf3ecb3198ff82a9fa
|
|
| BLAKE2b-256 |
7007fc0970fe8a62963aa2a0af0a698b8504e00fb559329f36d662022ac67a89
|