table(1) - Command line utility to format and display CSV.
0.6.22, 05 Oct 2023
tablep
is a synonym for
table -p.
tsvtable
is a synonym for
table -d "$(printf '\t')" -q ignore.
table [-h | --help]
table [-v | --version]
[-d|--delimiter= delim] [-f | --format= format] [-H | --align-header] [-m | --msdos] [-n | --no-ansi] [-p | --pause] [-q | --quotes= behavior] [-s | --symbols= set] [-t | --expand-tabs] [pathname]
table Copyright © 2020-2023 Strahinya Radich.
This program is licensed under GNU GPL v3 or later. See the file
LICENSE
in the table repository for details.
table is a command line utility to format and display CSV. It parses the given file or standard input as CSV and prints out a table using Unicode characters for box drawing.
When specifying multiple pathname arguments, table prints a warning to stderr. Only the first such argument is processed. If pathname is omitted, table reads standard input.
-a alignment
--align=alignment
Set column alignments.
alignment
is a string consisting of characters
l, c or r,
which respectively set the alignment of the corresponding column to left, center
or right.
For example, -arccc
sets the alignment for the first column to right, and
the next three columns to center.
-b
--border-mode
Border mode: force single column.
-c cols
--columns=cols
Set maximum table width in columns (default 80).
-D
--align-dot
Set alignment character to dot "." instead of a space " ".
-d delim
--delimiter=delim
Set field delimiter (default ","). First line of the input determines the number of table columns. The first character of delim becomes the delimiter. Special characters, like ";", need to be quoted or escaped:
$ table -d';'
or
$ table -d\;
In the examples above, "'" and "\" are parsed by the shell and are not passed to table, so are not considered as "first characters" for the assignment.
Note that the -b parameter takes precedence: if it is present, -d is ignored.
-f format
--format=format
Set widths for individual columns as ratio. Parameter format should be a string of weights separated by colons. For example:
$ table -c 50 -s aa examples/quotes-english.csv
+-----------+-----------+-----------+-----------+
|ID |Name |Surname |Age |
|001 |John |Smith |34 |
|002 |Steven |Watson |23 |
|003 |Richard |Smith |33 |
|007 |Bond, James|Bond |46 |
+-----------+-----------+-----------+-----------+
$ table -f 1:2:3:4 -c 50 -s aa examples/quotes-english.csv
+----+---------+-------------+------------------+
|ID |Name |Surname |Age |
|001 |John |Smith |34 |
|002 |Steven |Watson |23 |
|003 |Richard |Smith |33 |
|007 |Bond, Jam|Bond |46 |
+----+---------+-------------+------------------+
$ table -f 1:5:5:1 -c 50 -s aa examples/quotes-english.csv
+----+------------------+------------------+----+
|ID |Name |Surname |Age |
|001 |John |Smith |34 |
|002 |Steven |Watson |23 |
|003 |Richard |Smith |33 |
|007 |Bond, James |Bond |46 |
+----+------------------+------------------+----+
-H
--align-header
Makes the column alignment also apply to header row. The default behavior is to print header cells left-aligned.
-h
--help
Print the usage information screen.
-m
--msdos
Ignore carriage return (\r) characters in input. The default behavior is to treat them as part of the text, which can produce unexpected results.
-n
--no-ansi
Turn off ANSI SGR codes in the output. By default, the header row is printed in bold using ANSI codes. This switch prevents that.
-p
--pause
Presents the message "Press Enter to continue" and waits for input after outputting the table. This accounts for executing table from file managers which don't pause after executing programs or as a single command from terminal emulators.
-q behavior
--quotes=behavior
behavior can be one of the following:
process
Treats everything between the quotes as a single column. Treats consecutive quotes within the quoted text as literal quotes. This is the default.
ignore
Ignores the special meaning of quotes (like TSV). This is the default if table is called as tsvtable.
-s set
--symbols=set
Use table symbol set set for table lines, where set is one of the following (format: <border><inner border>):
aa | ascii-ascii, |
ss | single-single, |
sd | single-double, |
ds | double-single (default), |
dd | double-double, |
ee | empty-empty, |
ae | ascii-empty, |
se | single-empty, |
de | double-empty, |
ea | empty-ascii, |
es | empty-single, |
ed | empty-double. |
-t
--expand-tabs
Expand tabs to spaces, honoring standard modulo 8 tab stops. Default behavior is to output tab characters as-is.
Note that the -d parameter takes precedence, unless -b is also used: if the delimiter is set to the TAB character (0x09), -t is ignored. When -b is used in addition, -t is honored and -d ignored.
-v
--version
Print program version and exit.
awk(1), sed(1)
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
Strahinya Radich, https://strahinja.org
Bugs can be reported using the ticket tracker at: https://todo.sr.ht/~strahinja/table
commit b8c0350ca0de0d14af03e489c1b6f429ddb6301b Author: Страхиња Радић <contact@strahinja.org> Date: 2023-10-05T16:15:44+02:00 Update to 0.6.22 Signed-off-by: Страхиња Радић <contact@strahinja.org>