Version 19 of tabulate

Updated 2015-09-03 21:41:45 by Jorge

Tabulate is a command line utility that converts standard input into pretty-printed tables. It is also a Tcl module that does the same with lists of lists. It was inspired by https://github.com/joepvd/table . Tabulate works in Tcl 8.5+ and Jim Tcl.

It is currently developed as part of the Sqawk repository.

Download the latest version: curl https://raw.githubusercontent.com/dbohdan/sqawk/master/lib/tabulate.tcl > tabulate.tcl

Use example

Command line

$ ps | jimsh ./tabulate.tcl   
┌─────┬─────┬────────┬─────┐
│ PID │ TTY │  TIME  │ CMD │
├─────┼─────┼────────┼─────┤
│20583│pts/3│00:00:01│ zsh │
├─────┼─────┼────────┼─────┤
│23301│pts/3│00:00:00│  ne │
├─────┼─────┼────────┼─────┤
│28007│pts/3│00:00:00│  ps │
├─────┼─────┼────────┼─────┤
│28008│pts/3│00:00:00│jimsh│
└─────┴─────┴────────┴─────┘

tclsh

% source lib/tabulate.tcl
% ::tabulate::tabulate -data {{Hello World}}
┌─────┬─────┐
│Hello│World│
└─────┴─────┘

Discussion

JM 2015-08-03: I am probably doing something wrong:

 % info tclversion
 8.6
 % info patchlevel
 8.6.4
 % source tabulate.tcl
 % ::tabulate::tabulate -data {{Hello World!}}
 wrong # args: should be "dict exists dictionary key ?key ...?"

dbohdan 2015-08-03: I cannot reproduce that on my system by just following your transcript. Could you file an issue at https://github.com/dbohdan/sqawk/issues ?

JM 2015-08-03: never mind, I found the error on my side...there were spaces after the "\" line continuations, hence breaking the command. Somehow I got that from the copy-paste from the source.

 +------------------------------+
 ¦Thanks¦for¦sharing¦      ¦    ¦
 +------+---+-------+------+----¦
 ¦ This ¦ is¦   a   ¦second¦line¦
 +------------------------------+

Code

See https://github.com/dbohdan/sqawk/blob/master/lib/tabulate.tcl .

See also