Skip to content

Instantly share code, notes, and snippets.

@joshbode
Created August 17, 2013 01:57
Show Gist options
  • Select an option

  • Save joshbode/6254877 to your computer and use it in GitHub Desktop.

Select an option

Save joshbode/6254877 to your computer and use it in GitHub Desktop.
Testing CSV reading into LaTeX
\documentclass{article}
\usepackage{datatool}
\usepackage{booktabs}
\usepackage{xtab}
\usepackage{longtable}
\DTLloaddb{scientists}{scientists.csv}
\begin{document}
\begin{center}
\begin{tabular}{ll}
\toprule
\textbf{First Name} & \textbf{Last Name} \tabularnewline
\midrule
Josh & Bode \tabularnewline
Emily & Bode \tabularnewline
Ziggy & Bode \tabularnewline
\bottomrule
\end{tabular}
\end{center}
% using xtabular
\begin{center}
\tablecaption{Testing DTL}
\label{table:foo_dtl}
\tablehead{
\toprule
\textbf{First Name} & \textbf{Last Name} \tabularnewline
\midrule
}
\tabletail{\midrule}
\tablelasttail{\bottomrule}
\begin{xtabular}{ll}
\DTLforeach*{scientists}{\Name=name,\Surname=surname}{
\Name & \Surname
\DTLiflastrow{}{\tabularnewline}
}
\tabularnewline
\end{xtabular}
\end{center}
% using longtable
\begin{center}
\begin{longtable}{ll}
\caption{Testing DTL}
\label{table:foo_dtl_lt} \\
\toprule
\textbf{First Name} & \textbf{Last Name} \tabularnewline
\midrule
\endhead
\midrule
\endfoot
\bottomrule
\endlastfoot
\DTLforeach*{scientists}{\Name=name,\Surname=surname}{
\Name & \Surname
\DTLiflastrow{}{\tabularnewline}
}
\tabularnewline
\end{longtable}
\end{center}
\end{document}
name surname age
Josh Bode 33
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Albert Einstein 133
Marie Curie 145
Thomas Edison 165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment