TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new in latex and I have some issues. I want to read a .csv file in latex to create a table, but I don't know how. I heard that datatool package can do this, but I don't know how to use it.

My input is smth like this:


Thank you!


I think I found the answer of how to create a table based on a csv file. The name of the packages is actually csvtools.

share|improve this question

migrated from stackoverflow.com May 16 '12 at 23:36

This question came from our site for professional and enthusiast programmers.

csvtools is the old version of the package. The current version is indeed called datatool. – Alan Munn May 16 '12 at 23:54
up vote 14 down vote accepted

Assuming that the first row is the name of the columns, then you simply need to load the database via \DTLloaddb{myDB}{MyData.csv} where the file MyData.csv contains the contents as shown above, and the you can use the internal function \DTLdisplaydb{myDB} to print it as a table.

This table is very wide so I used the geometry package to extend the width of the paper. Here is the first few columns of the table:

enter image description here

If the first row is not the header row, then you can specify the key for each column as:

\DTLloaddb[noheader,keys={,ColW5, ColW6, ColW7}]{myDB}{MyData.csv}

where only keys for the first three columns have been included.



share|improve this answer
Thank you so much your the tips. – Ion Morozan May 16 '12 at 23:10
And if I don't want to take in consideration the first row? Because it has to be like w5 -> 5 to 6am. – Ion Morozan May 17 '12 at 10:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.