,==============================================. || __ | __| __ | || || / |_|_,______| |___| |____|__ || ||______| / | \ | \_______|| || | --/ -- | -- | | -- _/ || || \____/\_____/_|______/___\____\ || || | | | ||
# table Command line utility to format and display CSV. ## Manual See => https://strahinja.srht.site/man/table/table.1.html https://strahinja.srht.site/man/table/table.1.html ## Prerequisites * C compiler defaults in config.mk ## Install
$ git clone https://git.sr.ht/~strahinja/table
$ cd table
$ su
with => https://gameoftrees.org got:
$ got clone https://git.sr.ht/~strahinja/table
$ got checkout table.git
$ cd table
$ su
## Persistent build configuration file The file config.mk will be sourced when building targets which also accept configuration through environment variables. For example, CC and PREFIX can be specified in config.mk. ## OpenBSD Before running make(1), comment the CPPFLAGS definition in config.mk above the line with the “OpenBSD” comment and uncomment the one below it:
CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
-D_XOPEN_SOURCE=700 -D_BSD_SOURCE
Also, do the same for MANPREFIX:
MANPREFIX = $(DESTDIR)$(PREFIX)/man
## Install (Arch)
$ git clone https://aur.archlinux.org/table.git
$ cd table
$ makepkg -si
## Examples Periodically display CPU load information in a single-line table
$ watch "table /proc/loadavg -d ' ' -c 50 -n -s ss"
Format a long list of files in the current directory in a double line table with single-line column divisors
$ LC_ALL=C ls -l | tail -n +2 | sed -e 's/ +/ /g' | table -d ' ' -n
Print information from /etc/passwd in a table:
$ table -n -d : -f 3:1:1:1:4:4:4 /etc/passwd
Same as above, without borders and with different column alignment:
$ table -n -H -d: -arccclll -see -f3:1:1:1:4:4:4 /etc/passwd
## Configuring GNU Midnight Commander (mc) => https://www.midnight-commander.org GNU Midnight Commander file manager can be configured to use table as a viewer (F3) for CSV files. To do that, edit /usr/lib/mc/ext.d/text.sh (or make and edit a local copy, for example in ~/bin/text.sh, which we will assume here) so that
case "${filetype}" in
block in do_view_action() function includes:
csv)
table -m -n "${MC_EXT_FILENAME}"
;;
You also need to edit extension file (Command->Edit extension file) or just edit ~/.config/mc/mc.ext and add the lines:
shell/.csv
View=%view{ascii} ~/bin/text.sh view csv %var{PAGER:more}
before includes and default target. Bonus – TSV viewer: include
tsv)
tsvtable -m -n "${MC_EXT_FILENAME}"
;;
in `~/bin/text.sh` and
shell/.tsv
View=%view{ascii} ~/bin/text.sh view tsv %var{PAGER:more}
in `~/.config/mc/mc.ext`. ## Configuring ranger file manager => https://github.com/ranger/ranger ranger file manager can be configured to use table as a CSV file viewer. To do that, add the following to ~/.config/ranger/scope.sh, within the function handle_extension():
csv)
table -m "${FILE_PATH}" && exit 5
exit 1;;</pre>
Bonus – TSV viewer:
tsv)
tsvtable -m "${FILE_PATH}" && exit 5
exit 1;;
## Configuring vifm => https://vifm.info vifm file manager can also be configured to use table as a CSV file viewer. To accomplish this, add the following lines to ~/.config/vifm/vifmrc:
" CSV
fileviewer *.csv
\ table -m %c
Bonus – TSV viewer:
" TSV
fileviewer *.tsv
\ tsvtable -m %c
text/gemini
This content has been proxied by September (3851b).