I would like to create custom tables from .csv files. By custom I mean, that I only want LaTex to read in the body of the table, i.e. "a & b & ... \ ..." but I want to write my own header and formating around it (I know names and number of columns). I am aware of the package datatool, but this seems to only provide a function for loading an entire table (with a single header row constructed from variable names). I need to have multiple header rows for hierarchical grouping of columns however. Manual input of the numbers is not really an option - too many numbers ;)

How would I best do such a thing in LaTex?

  • Welcome to TeX.SE. t would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. And include some sample data, along with some details as to the hierarchical grouping that you are referring to. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. Commented Nov 7, 2014 at 7:59
  • My recent answer How to print addresses shows how to read a CSV without headers. Perhaps that will get your problem solved. If not, please make an attempt to show exactly what the problem is. Commented Nov 7, 2014 at 8:01
  • 1
    Using the datatool package, it is possible to add header rows above the default one by redefining \dtldisplaystarttab. On long tables, this will be added above the header line on all the pages. Other hooks are available, see p49 of the documentation. Commented Nov 7, 2014 at 8:15

1 Answer 1


Thank you @TonioElGringo, that does exactly what I was looking for. Here an example for a 3 column .csv file.

\renewcommand{\dtldisplaystarttab}{\multicolumn{3}{c}{I am what I was looking for!}\\}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .