/table

Command line utility to format and display CSV

Primary LanguageCGNU General Public License v3.0GPL-3.0

********************************************************************************
**** NOTE: THIS REPOSITORY HAS MOVED FROM GITHUB. NO FURTHER UPDATES WILL   ****
**** BE MADE HERE. FOR AN UP TO DATE VERSION OF table, PLEASE GO TO:        ****
****                 https://git.sr.ht/~strahinja/table                     ****
********************************************************************************

                                     table
                                     =====

Command line utility to format and display CSV.


                                    Install
                                    -------

$ git clone https://github.com/Strahinja/table.git
$ cd table
$ su

    Then, if you have apenwarr/redo[1]:

# redo install

    if you don't:

# ./do install


                                    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

    Like the above, but only permissions and file names are printed in a
    narrow table

        $ LC_ALL=C ls -l | tail -n +2 | awk '{ print $1 " " $9 }' \
            | table -d ' ' -c 30 -n


                    Configuring GNU Midnight Commander (mc)
                    ---------------------------------------

    GNU Midnight Commander[2] 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}</pre>

    before includes and default target.


                        Configuring ranger file manager
                        -------------------------------

    Ranger[3] 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
        csv)
            table -m "${FILE_PATH}" && exit 5
            exit 1;;


                                Configuring vifm
                                ----------------

    Vifm[4] 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


[1]: https://github.com/apenwarr/redo
[2]: https://www.midnight-commander.org
[3]: https://github.com/ranger/ranger
[4]: https://vifm.info


                                    License
                                    -------

    table - Command line utility to format and display CSV.
    Copyright (C) 2020, 2021  Страхиња Радић

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.