Skip to main content

Ascii Table Output

· 2 min read
Alan Richardson

Can now output as Ascii Tables.

Ascii Tables

Output Ascii Tables can be useful for writing tabular content in emails, code or generally making notes in text files.

e.g.

+----------+----------+----------------------------+
| test | name | email |
+----------+----------+----------------------------+
| 41211470 | Cyril | Tianna_Kris@gmail.com |
| 4199130 | Andreane | Isac.Mills92@gmail.com |
| 9258363 | Mariam | Abner_Feeney82@hotmail.com |
| 93931922 | Desiree | Josh48@yahoo.com |
+----------+----------+----------------------------+

Note: Data in table above was generated by the faker test generation in the tool

The schema used for the data table was:

test
[0-9]{3,10}
name
name.firstName
email
internet.email

Ascii Table Libraries

There are a variety of libraries available to support in this, and I listed a few in the docs

I initially tried Ascii-Table this was very easy to import from a CDN and I was able to create a prototype very quickly. I thought it lacked some of the more advanced configuration I was looking for and didn't think I'd be able to support as many export formats as I'd like e.g. reStructuredText

So I moved on to Ascii-Table3 which has the very useful feature of being able to create styles to set a lot of configuration very quickly, it also allows more detailed configuration of the borders for the table.

The problem here was that Ascii-Table3 is really designed for server side usage and has a requirement on a file system library to import styles. To get something working quickly I amended the import mechanism to allow it to work in the browser. This is an unofficial port with the code being available in the github repo.

The styles feature of Ascii-Table3 allowed me to add a drop down on the GUI to select different styles of tables without too much development effort.