# Tablify: Tool to render CSV into tables of various formats

[ bsd3, program, text ] [ Propose Tags ]

Tool to render CSV into tables of various formats, including HTML, tbl, and character art (both ASCII and Unicode)

#### Maintainer's Corner

For package maintainers and hackage trustees

Candidates

• No Candidates
Versions [RSS] 0.8, 0.8.1, 0.8.2 base (<5), parsec (<4), xhtml [details] BSD-3-Clause © 2009-2011 Daniel Lyons Daniel Lyons Daniel Lyons Text http://www.storytotell.org/code/tablify by DanielLyons at 2011-04-21T06:22:06Z NixOS:0.8.2 tablify 2829 total (5 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs not available Last success reported on 2016-10-26

[back to package description]
tablify - a simple utility for formatting CSV files.
by Daniel Lyons <fusion@storytotell.org>

What it does:

Tablify is a simple program which does nothing but parse CSV files and render
them into various display-friendly formats. I spend a fair amount of my time
dealing with data migration and sometimes it's handy to look at the data
directly or publish it in such a fashion as other people may find it
convenient.

Tablify does not understand every possible CSV format; I took the CSV code
from the book Real World Haskell. I am not particularly interested in adding
support for other varieties of CSV because this parser seems to handle the
common cases and generally if you are getting something else, it's because
you asked for something weird. Please let me know if this is not the case for
you.

A major rationale for this application was that I noticed that there are some
nice characters in the Unicode standard for drawing boxes. I used to draw
boxes for text files like this:

+--------------+-----+
| Name         | Age |
+--------------+-----+
| Daniel Lyons | 28  |
| Reid Givens  | 29  |
+--------------+-----+

This works OK (it's what MySQL and PostgreSQL's command line clients do,
after all.) But how much cooler does this look:

┌──────────────┬─────┐
│ name         │ age │
├──────────────┼─────┤
│ Daniel Lyons │ 28  │
│ Reid Givens  │ 29  │
└──────────────┴─────┘

If you have a nice Unicode font like Menlo on your machine, that should look
freaking awesome. This is what you get using the -U flag. If you want the old
fugly ASCII table, use -A.

Anyway, it occurred to me while writing it that I could quite easily support
a few other formats, so I wrote an HTML output routine and a TBL output
routine, TBL being part of troff or groff depending on your system.

The HTML output routine escapes HTML entities (<, > and &). I expect if you
actually use TBL you will want to tinker with what it gives you. I haven't
embellished the system with any justification alternatives besides left
justification; this is really only an issue for the Unicode output option.

The program assumes that your input and your output are both UTF-8. There are
utilities you can use such as iconv to fix files coming in or going out if
that's not your situation. You may specify many files on the command line, or
- if you want it to read from standard input.

Enjoy!

Dependencies:

These are generally included with GHC:

• parsec
• regex-compat

Building:

Run these three commands ($represents your shell's prompt):$ runhaskell Setup.hs configure
$runhaskell Setup.hs build$ sudo runhaskell Setup.hs install

Alternatively, if you have the cabal utility installed, you can run:

$cabal configure$ cabal build
\$ cabal install

Contacting me:

If you run into any bugs or think of a feature you'd like me to add, please
email me at fusion@storytotell.org and tell me about it.