Re: New coreutil suggestion - tableize (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
From: | Pádraig Brady |
---|---|
Subject: | Re: New coreutil suggestion - tableize |
Date: | Sat, 26 Nov 2011 16:27:38 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 11/26/2011 01:23 PM, Guillaume Kielwasser wrote:
tableize is a small text utility that prints a table from a formatted file or standard input. Example:
$ cut -d':' -f1,3-6 /etc/passwd | head | tableize -sd':' +--------+---+-------+--------+-----------------+ | root | 0 | 0 | root | /root | | daemon | 1 | 1 | daemon | /usr/sbin | | bin | 2 | 2 | bin | /bin | | sys | 3 | 3 | sys | /dev | | sync | 4 | 65534 | sync | /bin | | games | 5 | 60 | games | /usr/games | | man | 6 | 12 | man | /var/cache/man | | lp | 7 | 7 | lp | /var/spool/lpd | | mail | 8 | 8 | mail | /var/mail | | news | 9 | 9 | news | /var/spool/news | +--------+---+-------+--------+-----------------+
Package home page for now: http://www.gnuwakes.org/index.php?option=comcontent&view=article&id=54:tab-09-released&catid=36:tab&Itemid=58
During tableize's GNU evaluation, it appeared that the coreutils could be the right place to be for this tool, even if it's not ready for a coreutils' integration right now.
Looking for feedback, comments, experience, tableize is still in development and nothing's written in the stone yet (options, program name, etc.).
Any input appreciated.
Thanks Guillaume,
That does seem useful, though similar logic exists already:
$ head /etc/passwd | column -t -s: root x 0 0 root /root /bin/bash bin x 1 1 bin /bin /sbin/nologin daemon x 2 2 daemon /sbin /sbin/nologin adm x 3 4 adm /var/adm /sbin/nologin lp x 4 7 lp /var/spool/lpd /sbin/nologin sync x 5 0 sync /sbin /bin/sync shutdown x 6 0 shutdown /sbin /sbin/shutdown halt x 7 0 halt /sbin /sbin/halt mail x 8 12 mail /var/spool/mail /sbin/nologin uucp x 10 14 uucp /var/spool/uucp /sbin/nologin
$ python -m prettytable +-----------+------+------------+-----------------+ | City name | Area | Population | Annual Rainfall | +-----------+------+------------+-----------------+ | Adelaide | 1295 | 1158259 | 600.5 | | Brisbane | 5905 | 1857594 | 1146.4 | | Darwin | 112 | 120900 | 1714.7 | | Hobart | 1357 | 205556 | 619.5 | | Sydney | 2058 | 4336374 | 1214.8 | | Melbourne | 1566 | 3806092 | 646.9 | | Perth | 5386 | 1554769 | 869.4 | +-----------+------+------------+-----------------+
Hmm, I wonder would it be worth augmenting column -t
from util-linux
to add a --border option and also detect number cols and auto right align?
I guess a --header option would be useful too.
Note column
is not specific to GNU/Linux of course, so perhaps
in time it may be moved to coreutils.
Note both util-linux and coreutils use a multi-byte aware alignment module¹,
which may be useful, which you can see with the output from:
$ df -B'1 | head -n3 #² Filesystem 1B-blocks Used Available Use% Mounted on rootfs 13,416,660,992 8,771,010,560 4,509,388,800 67% / udev 1,489,645,568 0 1,489,645,568 0% /dev
$ LANG=lt_LT.utf8 cal -3 spalio 2011 lapkričio 2011 gruodžio 2011 Sk Pr An Tr Kt Pn Št Sk Pr An Tr Kt Pn Št Sk Pr An Tr Kt Pn Št 1 1 2 3 4 5 1 2 3 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 30 31
¹ http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=gl/lib/mbsalign.h;hb=HEAD ² Since coreutils 8.11
I also notice there is logic to consume such tables. This also notes other possible formatting options. http://cxc.harvard.edu/contrib/asciitable/
cheers, Pádraig.
- New coreutil suggestion - tableize, Guillaume Kielwasser, 2011/11/26
- Re: New coreutil suggestion - tableize,Pádraig Brady <=
* Re: New coreutil suggestion - tableize, Guillaume Kielwasser, 2011/11/27
- Re: New coreutil suggestion - tableize,Pádraig Brady <=
- Prev by Date:New coreutil suggestion - tableize
- Next by Date:[PATCH] maint: update comment gcc-4.6.2 still botches -Wsuggest-attribute=pure
- Previous by thread:New coreutil suggestion - tableize
- Next by thread:Re: New coreutil suggestion - tableize
- Index(es):