1

I'm trying make a table with the datatool package and a .csv created from an Excel file. I'd like this code to be as generic as possible since I will have to import a lot of .csv in this document. With this code, I can add vertical lines before, between and after the table and horizontal lines between rows. I'd like to add horizontal lines before the headers, after the headers and at the bottom of the table. I've tried every single tweak I have read, but I'm still failing. I would appreciate some help. link yo .csv file

\documentclass[spanish]{report}
\usepackage{datatool}
\DTLsetseparator{;}
\usepackage[capposition=top]{floatrow}
\begin{document}
    \begin{table}[H]
    \centering
    \captionsetup{justification=centering}
    \caption{Tabla vientos}
    \DTLloaddb[noheader, keys={a,b,c,d,e,f,g,h,i,j,k},%
        headers={
        \shortstack{dirección\\del viento},%
        \shortstack{0-3},%
        \shortstack{4-6},%
        \shortstack{7-10},%
        \shortstack{11-16},%
        \shortstack{17-21},%
        \shortstack{22-27},%
        \shortstack{28-33},%
        \shortstack{34-40},%
        \shortstack{>41},%
        \shortstack{Total}}]{myDB}{viento.csv} 
    \renewcommand{\dtldisplaystarttab}{\multicolumn{11}{c}{I am what I was looking for!}\\}
    \renewcommand{\dtlbeforecols}{|}
    \renewcommand{\dtlaftercols}{|}
    \renewcommand{\dtldisplaycr}{\tabularnewline \hline}
    \renewcommand{\dtlbetweencols}{|}
    \DTLdisplaydb{myDB}
    \end{table}
\end{document}
  • Instead of the current code snippet, could you also provide the community with a small (but workable) CSV and make the document code compile? – Werner Mar 5 '15 at 3:54
  • Sure I can! How can I add a .csv? – Fran Mar 5 '15 at 11:11
  • It does compile now and I've added a link to the original .csv – Fran Mar 5 '15 at 11:21
1

After reading (again) the documentation for the datatool package I've found some commands that helped me doing what I wanted. In case someone have the same trouble, these are the commands

\renewcommand{\dtldisplayafterhead}{\hline \hline}

For adding two horizontal lines after the header

\renewcommand{\dtldisplayendtab}{\tabularnewline \hline \hline}

For adding two horizontal lines at the end of the table

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

For adding two lines before the headers as well as a text before these two lines

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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