MyNixOS website logo
Description

Simple tool to generate tables from DSV input.

table

Formats lines of TSV, CSV, or DSV (delimiter-separated values) into a pretty plain text table, wrappings cells with long content to try to fit the table in the screen.

Usage

table

Usage: table ([-d DELIM] | [-s]) [-c] [-R] [-H] [-w WIDTH]
  Pretty format TSV input into table with aligned and wrapped cells

Available options:
  -h,--help                Show this help text
  -d DELIM                 Input field delimiter. Default is TAB (\t).
  -s                       Use any run of whitespace as input field delimiter
  -c                       Parse input as CSV
  -R                       Don't print row dividers
  -H                       Print header row divider
  -w WIDTH                 Max table width. Defaults to value of `tput cols`
                           command.

https://github.com/danchoi/table

Example

Format Rails issues from the GitHub API into a table. This example uses jq and jsontsv to transform the GitHub API JSON into tab separated values before piping that data into table:

curl -s "https://api.github.com/repos/rails/rails/issues" | 
jq -M '.[]' | 
jsontsv -H 'number title user.login:user state' |
table

Outputs this when the terminal width is 72 characters:

--------+--------------------------------------+----------------+-------
 number | title                                | user           | state 
--------+--------------------------------------+----------------+-------
  18290 | Updating guides for Rails 5.0        | lucascaton     | open  
--------+--------------------------------------+----------------+-------
  18288 | Add --skip-action-mailer (or -M) to  | claudiob       | open  
        | rails generate                       |                |       
--------+--------------------------------------+----------------+-------
  18287 | Rails 4.2.0: Scaffold generator      | dldinternet    | open  
        | with --helper=false produced an      |                |       
        | error                                |                |       
--------+--------------------------------------+----------------+-------
  18285 | undefined method 'clear' for         | nPn-           | open  
        | nil:NilClass in                      |                |       
        | actionpack-4.2.0/lib/action_controll |                |       
        | er/test_case.rb                      |                |       
--------+--------------------------------------+----------------+-------
  18283 | Prefer `array?` rather than `array`  | kamipo         | open  
--------+--------------------------------------+----------------+-------
  18279 | Refactoring of add_constraints in    | eileencodes    | open  
        | AssociationScope                     |                |       
--------+--------------------------------------+----------------+-------
  18273 | Rails 3.2.21 (4.x too?):             | jensb          | open  
        | attribute_will_change! with symbol   |                |       
        | parameter causes "multiple           |                |       
        | assignment" error in Postgres        |                |       
--------+--------------------------------------+----------------+-------
  18257 | ActionView::Helpers::TranslationHelp | jcoyne         | open  
        | er.translate makes unsafe values     |                |       
        | html_safe                            |                |       
...

You can use table to pretty-format TSV output for mysql, psql, or sqlite3 as well, especially when you need row cell content to wrap to fit everything nicely on the screen.

Author

License

MIT License.

Metadata

Version

0.1.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows