About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-10-15: New blog post: Tales for Our Times Book Launch.

Display Product List (CSV)

This code requires booklist.csv, people.csv and country-codes.csv.

\documentclass[captions=tableheading]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{longtable}% required for \DTLdisplaylongdb
\usepackage{datatool}

\DTLloaddb{products}{booklist.csv}

\DTLloaddb{customers}{people.csv}

\DTLloaddb{countries}{country-codes.csv}

\begin{document}

First an example that just uses the \texttt{table} and
\texttt{tabular} environments. See Table~\ref{tab:products}.

\begin{table}
  \caption{A Sample Product List}
  \label{tab:products}
  \centering
  \DTLdisplaydb{products}
\end{table}

Data loaded from a CSV file has empty rather than null values.
See Table~\ref{tab:customers}.

\begin{table}
  \caption{A Sample Customer List}
  \label{tab:customers}
  \centering
  \DTLdisplaydb
   [id,forenames,title,country,postcode,dob]% omit these columns
  {customers}
\end{table}

If the data is too large to fit on a single page we need to use the
\texttt{longtable} environment instead. See Table~\ref{tab:countries}.

\DTLdisplaylongdb
 [
   caption={A Sample Long Table},% main caption
   contcaption={A Sample Long Table (Continued)},% continuation caption
   label={tab:countries},% label
   foot={\emph{Continued on next page}},% table foot
   lastfoot={}% final table foot
 ]
 {countries}

\end{document}

Download sample-datatooltk-csv.tex or sample-datatooltk-csv.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs