Today, I had to create a paste a table of values into a JIRA ticket and I had a csv file. There are different ways to “paste” a nicely formatted table into a JIRA WYSIWYG text area, I’m sure.. but none of them fast enough to type: $csv2html source.csv destation.html
. So, I wrote one.
You can find it here https://github.com/btbytes/csv2html. The help is self explanatory:
$./csv2html.py -h
usage: csv2html.py [-h] [--delimiter DELIMITER] [--quotechar QUOTECHAR]
[--title TITLE] [--caption CAPTION] [--header]
csvfile
CSV to HTML converter.
positional arguments:
csvfile
optional arguments:
-h, --help show this help message and exit
--delimiter DELIMITER
Field delimiter. Default is , .
--quotechar QUOTECHAR
Quote Character. Deault is nothing
--title TITLE Page title. Will be printed in h1 tag.
--caption CAPTION Table caption.
--header data has header. First row will be "th".
Ideally, I’d have liked to use the pandoc-csv2table pandoc filter. But, installing this filter using cabal
and stack
turned out to be disappointing. So instead of figuring out how to compile and install these Haskell packages, I wrote this script.
I can still do some improvements to this script, like:
a. adding an -o --output
flag to write the output to a file instead of stdout.
b. override the css
But, that’s for another day.