Roland's homepage

My random knot in the Web

csv2tbl

The csv2tbl.py script takes a comma-separated values (“csv”) file, and converts it to a LaTeX table. It handles a couple of different possible seperators; semicolon, comma and tab. Of those it automatically pics the one that occurs most.

N.B.: it does not try to interpret quotation marks!

It uses the booktabs package for a more typgraphically neat look of the generated table. To use these generated tables in yout LaTeX document, put the following in its preamble:

\usepackage{booktabs}

And then incorporate the generated table (assuming you’ve saved it as the file csvtable.tex) in your document:

\input{csvtable}

N.B.: You should generally not use \include here instead of \input here. It forces page breaks around the incorporated text, among other things.

It should be compatible with both python2 and python3, although it calls the latter in the first line of the script. Change that to suit your needs.

The script is available on github.

Note

The script is now compatible with both Python 2 and Python 3. But it uses the latter by default. Change the first line of the script if you want to use Python 2. In that case you should also add the following line to the script:

from __future__ import print_function

For comments, please send me an e-mail.


Related articles


←  dxftools Formatting git changelogs for LaTeX  →