Guile-DSV is a GNU Guile module for working with the delimiter-separated values (DSV) data format.
Guile-DSV supports the Unix-style DSV format and RFC 4180 format.
Also Guile-DSV ships with a program named dsv
(source code is here:
utils/dsv.in
) that allows to read and process DSV format (including
delimiter change and conversion from one standard to another.)
- GNU Guile 2.0.12+
- Guile Library 0.1.9+
- Texinfo (contains
makeinfo
tool that is required for making the documentation in Texinfo format) - Texlive (also is needed for documentation.)
Files:
- AUTHORS contains list of people who contributed to the library development.
- COPYING contains the terms of GNU General Public License.
- INSTALL contains general instructions for building/installing of Guile-DSV
- NEWS describes user-visible changes.
- TODO contains plans for the further development and list of known bugs.
Directories:
- doc – Documentation in Texinfo format.
- modules – Guile modules.
- presets – Table presets.
- utils – Utility programs based on Guile-DSV.
- tests – Unit tests.
Files are usually installed according to the prefix specified to
configure
script, /usr/local
by default. Building and installing gives
you:
Guile modules, in ${GUILE_SITE}
:
- dsv.scm
- dsv/config.scm
- dsv/rfc4180.scm
- dsv/unix.scm
- dsv/parser.scm
- dsv/builder.scm
- dsv/common.scm
- dsv/table.scm
- dsv/table-preset.scm
- dsv/cli/common.scm
All the modules will be compiled and produced .go files will be installed
to site-ccache
directory which is something like this:
${libdir}/guile/2.0/site-ccache/
.
Documentation in Info format, in ${prefix}/share/info/
:
- guile-dsv.info
Utility program in ${PREFIX}/bin
:
- dsv
For a basic explanation of the installation of the package, see the INSTALL file.
Please note that you will need Automake 1.12 or later to run
self-tests with make check
(but the library itself can be built with
older Automake version such as 1.11).
important You probably want to call configure with the
--with-guilesitedir
option so that this package is installed in
Guile’s default path. But, if you don’t know where your Guile site
directory is, run configure
without the option, and it will give you
a suggestion.
$ dsv --help Usage: dsv [options] <file> The default behavior of the program is to print a formatted table from a <file> to stdout. The options listed below can be used to change or modify this behavior. Options: --help, -h Print this message and exit. --summary, -s Print summary information for a file. --delimiter, -D <delim> Set a delimiter. --guess-delimiter, -d Guess a file delimiter and print the result. --file-format, -F <fmt> Set a file format. Possible formats are: "unix" (default), "rfc4180" --with-header, -H Use the first row of a table as a header when printing the table to the screen. --table-borders, -b <spec> Set table borders for printing. The value can be either a borders specification or a preset name. Spec is expected to be a comma-separated list of key=value pairs. The list of possible keys can be found below (see "Table parameters".) Example values: - "v=|,h=-,j=+" --to, -t <fmt> Convert a file to a specified format, write the result to stdout. --to-delimiter, -T <delim> Convert delimiters to the specified variant. When this option is not used, default delimiters for the chosen output format will be used. --debug Enable state machine debugging. Table parameters: bt border-top btl border-top-left btr border-top-right btj border-top-joint bl border-left blj border-left-joint br border-right brj border-right-joint bb border-bottom bbl border-bottom-left bbr border-bottom-right bbj border-bottom-joint rs row-separator rj row-joint cs column-separator ht header-top htl header-top-left htr header-top-right htj header-top-joint hl header-left hr header-right hcs header-column-separator hb header-bottom hbl header-bottom-left hbr header-bottom-right hbj header-bottom-joint Table presets: ascii graphic-bold graphic-double graphic org
To show DSV files (Unix-style) in human-readable manner, just invoke the tool like this:
$ dsv /etc/passwd | head -3 root x 0 0 root /root /bin/bash daemon x 1 1 daemon /usr/sbin /usr/sbin/nologin bin x 2 2 bin /bin /usr/sbin/nologin
Show a DSV file as a fancy table with custom borders:
$ dsv -b "rs=-,cs=|,rj=+" /etc/passwd | head -5 root | x | 0 | 0 | root | /root | /bin/bash --------------------------+--------+------------+------------+-----------------------------------------+---------------------------------+------------------------ daemon | x | 1 | 1 | daemon | /usr/sbin | /usr/sbin/nologin --------------------------+--------+------------+------------+-----------------------------------------+---------------------------------+------------------------ bin | x | 2 | 2 | bin | /bin | /usr/sbin/nologin
The same output but with box-drawing characters:
$ head -3 /etc/passwd | dsv -b "rs=─,cs=│,rj=┼" root │ x │ 0 │ 0 │ root │ /root │ /bin/bash ─────────────┼────────┼────────┼────────┼─────────────┼────────────────┼──────────────────────── daemon │ x │ 1 │ 1 │ daemon │ /usr/sbin │ /usr/sbin/nologin ─────────────┼────────┼────────┼────────┼─────────────┼────────────────┼──────────────────────── bin │ x │ 2 │ 2 │ bin │ /bin │ /usr/sbin/nologin
There are table presets that can be used to draw tables with specified border styles. Some examples:
$ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "ascii" .-----------------------------. | a | b | c | |---------+---------+---------| | a1 | b1 | c1 | |---------+---------+---------| | a2 | b2 | c2 | '-----------------------------' $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "ascii" --with-header .-----------------------------. | a | b | c | |=========+=========+=========| | a1 | b1 | c1 | |---------+---------+---------| | a2 | b2 | c2 | '-----------------------------' $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "graphic" ┌─────────┬─────────┬─────────┐ │ a │ b │ c │ ├─────────┼─────────┼─────────┤ │ a1 │ b1 │ c1 │ ├─────────┼─────────┼─────────┤ │ a2 │ b2 │ c2 │ └─────────┴─────────┴─────────┘ $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "graphic-bold" ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓ ┃ a ┃ b ┃ c ┃ ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫ ┃ a1 ┃ b1 ┃ c1 ┃ ┣━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━┫ ┃ a2 ┃ b2 ┃ c2 ┃ ┗━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━┛ $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "graphic-double" ╔═════════╦═════════╦═════════╗ ║ a ║ b ║ c ║ ╠═════════╬═════════╬═════════╣ ║ a1 ║ b1 ║ c1 ║ ╠═════════╬═════════╬═════════╣ ║ a2 ║ b2 ║ c2 ║ ╚═════════╩═════════╩═════════╝ $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "org" | a | b | c | | a1 | b1 | c1 | | a2 | b2 | c2 | $ echo -e "a,b,c\na1,b1,c1\na2,b2,c2\n" | dsv -b "org" --with-header | a | b | c | |---------+---------+---------| | a1 | b1 | c1 | | a2 | b2 | c2 |
$ dsv -d /etc/passwd :
$ dsv -s /etc/passwd File: /etc/passwd Format: unix Delimiter: ':' (0x3a) Records: 50 column width 1 19 2 1 3 5 4 5 5 34 6 26 7 17
From Unix DSV to RFC4180:
$ dsv -t rfc4180 /etc/passwd | head -4 root,x,0,0,root,/root,/bin/bash daemon,x,1,1,daemon,/usr/sbin,/usr/sbin/nologin bin,x,2,2,bin,/bin,/usr/sbin/nologin sys,x,3,3,sys,/dev,/usr/sbin/nologin
Convert delimiters:
$ dsv -t unix -T "|" /etc/passwd | head -4 root|x|0|0|root|/root|/bin/bash daemon|x|1|1|daemon|/usr/sbin|/usr/sbin/nologin bin|x|2|2|bin|/bin|/usr/sbin/nologin sys|x|3|3|sys|/dev|/usr/sbin/nologin