README (3624B)
1 table 2 ===== 3 4 Command line utility to format and display CSV and TSV. 5 6 For installation instructions, see the file INSTALL. 7 8 9 Examples 10 -------- 11 12 Periodically display CPU load information in a single-line table (requires a 13 mounted Linux-style /proc file system and GNU watch(1)) 14 15 $ watch "table /proc/loadavg -d ' ' -c 50 -n -s ss" 16 17 Format a long list of files in the current directory in a double line table with 18 single-line column divisors 19 20 $ LC_ALL=C ls -l | tail -n +2 | sed -E 's/ +/ /g' | table -d ' ' -n 21 22 Caution: format of ls(1) is not standardized, so this example might not work as 23 intended. 24 25 Print information from /etc/passwd in a table: 26 27 $ table -n -d : -f 3:1:1:1:4:4:4 /etc/passwd 28 29 Same as above, without borders and with different column alignment: 30 31 $ table -n -H -d: -arccclll -see -f3:1:1:1:4:4:4 /etc/passwd 32 33 34 35 Configuring GNU Midnight Commander (mc) 36 --------------------------------------- 37 38 GNU Midnight Commander[2] file manager can be configured to use table as a 39 viewer (F3) for CSV files. To do that, edit /usr/lib/mc/ext.d/text.sh (or make 40 and edit a local copy, for example in ~/bin/text.sh, which we will assume here) 41 so that 42 43 case "${filetype}" in 44 45 block in do_view_action() function includes: 46 47 csv) 48 table -m -n "${MC_EXT_FILENAME}" 49 ;; 50 51 You also need to edit extension file (Command->Edit extension file) or just edit 52 ~/.config/mc/mc.ext (before version 4.8.*) and add the lines: 53 54 shell/.csv 55 View=%view{ascii} ~/bin/text.sh view csv %var{PAGER:more} 56 57 or ~/.config/mc/mc.ext.ini (versions 4.8.* and later): 58 59 [csv] 60 Shell=.csv 61 View=%view{ascii} ~/bin/text.sh view csv %var{PAGER:more} 62 63 before includes and default target. 64 65 Bonus – TSV viewer: include 66 67 tsv) 68 tsvtable -m -n "${MC_EXT_FILENAME}" 69 ;; 70 71 in ~/bin/text.sh and (before version 4.8.*) 72 73 shell/.tsv 74 View=%view{ascii} ~/bin/text.sh view tsv %var{PAGER:more} 75 76 in ~/.config/mc/mc.ext, or (versions 4.8.* and later): 77 78 [tsv] 79 Shell=.tsv 80 View=%view{ascii} ~/bin/text.sh view tsv %var{PAGER:more} 81 82 in ~/.config/mc/mc.ext.ini. 83 84 85 Configuring ranger file manager 86 ------------------------------- 87 88 Ranger[3] file manager can be configured to use table as a CSV file viewer. To 89 do that, add the following to ~/.config/ranger/scope.sh, within the function 90 handle_extension(): 91 92 ## CSV 93 csv) 94 table -m "${FILE_PATH}" && exit 5 95 exit 1;; 96 97 Bonus – TSV viewer: 98 99 ## TSV 100 tsv) 101 tsvtable -m "${FILE_PATH}" && exit 5 102 exit 1;; 103 104 105 Configuring vifm 106 ---------------- 107 108 Vifm[4] file manager can also be configured to use table as a CSV file viewer. 109 To accomplish this, add the following lines to ~/.config/vifm/vifmrc: 110 111 " CSV 112 fileviewer *.csv 113 \ table -m %c 114 115 Bonus – TSV viewer: 116 117 " TSV 118 fileviewer *.tsv 119 \ tsvtable -m %c 120 121 122 [1]: https://github.com/apenwarr/redo 123 [2]: https://www.midnight-commander.org 124 [3]: https://github.com/ranger/ranger 125 [4]: https://vifm.info 126 127 128 License 129 ------- 130 131 table - Command line utility to format and display CSV 132 Copyright (C) 2020-2026 Страхиња Радић 133 134 This program is free software: you can redistribute it and/or modify it under 135 the terms of the GNU General Public License as published by the Free Software 136 Foundation, either version 3 of the License, or (at your option) any later 137 version. 138 139 This program is distributed in the hope that it will be useful, but WITHOUT ANY 140 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 141 PARTICULAR PURPOSE. See the GNU General Public License for more details. 142 143 You should have received a copy of the GNU General Public License along with 144 this program. If not, see <https://www.gnu.org/licenses/>.