Align columns in ASCII tables


Keywords
ascii, pretty-print, tables, vim
Licenses
GPL-3.0/GPL-3.0+
Install
pip install tablign==0.3.7

Documentation

tablign

Aligns columns in your ASCII tables.

PyPi Version PyPI pyversions GitHub stars PyPi downloads

gh-actions codecov Code style: black

Install with

pip install tablign
tablign in.txt out.txt

you can convert your input file

| A | 1.34|-214.1|
|CCCC | 55.534|   1131.1|

into

| A    |  1.34  | -214.1 |
| CCCC | 55.534 | 1131.1 |

Column widths are unified across the table, decimal dots are aligned, and tablign tries to be smart about column separators. Works for CSV, LaTeX, Markdown etc. By default, tablign reads from stdin and writes to stdout, so you can use pipes with tablign, too:

head -n in.txt | tablign

Usage from vim

Simply mark the table (shift-V), and type

:'<,'>:!tablign

Alternatives

GNU's column command is a mighty alternative:

column -t

See here for more alternatives.