# display csv database content

I am a newbie. I need to create a catalogue of the main opera (classic voice) courses in Europe. Each school gets its own page. Each page has specific information about the school: name of the school, adress, name of the degree (master, certificate...), website of the degree (a link), fee, application deadline, start date, duration, contact person.. and so on.

As far as I can tell, a good course of action would be to create a csv file (targets.csv) and then use datatool to display its content in a table. This in theory; in practice it doesn't work (for me). Here's my targets.csv file:

id,institute,address,degree,websitedegree,fee,applicationfee,applicationdl,startdate,duration,contactperson,cptitle,cpcontact,actionplanned,actiontaken,furtheraction,fadl,lastupdate
1,%id
The Juilliard School,%institute
60 Lincoln Center Plaza New York NY 10023,%address
Master of Science in Voice,%degree
62000 dollars per year (a.i.),%fee
120 dollars,%application feed
smtg,%start date
2 years,%duration
na na na,%contact person
na na na,%cp title
mail,%cp contact
apply,%action planned
20.07.2015: scheduled recording session for audition,%action taken
record prescreening audition according to the repertoire,%further action
\today%last update


and my main.tex file:

\documentclass{article}
\usepackage[showframe,paperwidth=32cm]{geometry}
\usepackage{hyperref}
\usepackage{datatool}

\begin{document}
\noindent\DTLdisplaydb{myDB}
\end{document}


I get the following error:

! File ended while scanning use of \@dtl@trim.
<inserted text>
\par
<*> main.tex
I suspect you have forgotten a }', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type E' or X' now and fix your file.
! Emergency stop.
<*> main.tex
*** (job aborted, no legal \end found)


• AFAIK the csv file should have all fields in the same line, separated by commas. If some line does not contain all data, it must contain the commas. For example, foo,,,,,,,,,, if only the 1st field has data. Insert new line for another data. – Sigur Jul 24 '15 at 10:50
• Thank you. It works wonderful. Would it possible to use one and only one table to display all the entries in the csv file? I mean, devoting one entire page to each of them is not visually effective. I think one big table will do the job. What package (or other relevant strategy) should I use to get the result? Thank you – Furbenzio Jul 24 '15 at 13:34
• @user82528 It's simple. You have to use \DTLdisplaylongdb{myDB}, which is based on the special environment longtable. This environment is able to break a table between two or more page. – skevin93 Jul 25 '15 at 9:53

Your problem is inside csv file: you separate each field with a comma and then insert a newline. The newline interference with the parser macro, which search only the comma as field delimiter. When find a newline, it read as a row delimiter and begin a new row, without complete the reading of all field declared in the head. So, a solution is remove all the newline and have all the field on a single row.

id,institute,address,degree,websitedegree,fee,applicationfee,applicationdl,startdate,duration,contactperson,cptitle,cpcontact,actionplanned,actiontaken,furtheraction,fadl,lastupdate
1,"The Juilliard School","60 Lincoln Center Plaza New York NY 10023","Master of Science in Voice", "\href{http://www.juilliard.edu/apply-audition/application-audition-requirements/master-music-and-graduate-diploma-table-contents}{website}(to be updated 2016)","62000 dollars per year (a.i.)","120 dollars","1.12.2015 (to be confirmed)",smtg,"2 years","na na na","na na na",mail,apply,"20.07.2015: scheduled recording session for audition","record prescreening audition according to the repertoire","15.09.2015","\noexpand\today"
1,"The Juilliard School","60 Lincoln Center Plaza New York NY 10023","Master of Science in Voice", "\href{http://www.juilliard.edu/apply-audition/application-audition-requirements/master-music-and-graduate-diploma-table-contents}{website}(to be updated 2016)","62000 dollars per year (a.i.)","120 dollars","1.12.2015 (to be confirmed)",smtg,"2 years","na na na","na na na",mail,apply,"20.07.2015: scheduled recording session for audition","record prescreening audition according to the repertoire","15.09.2015","\noexpand\today"


Moreover, when you add a field with blank space inside, you need to enbrace it inside two doublequotes, because blank space can be troublesome.

Here I put a WME, where I use the environment DTLenvforeach instead of \DTLdisplaydatabase. This environment allow you to read row per row the database and use each column, assigning them to a macro. I put a \newpage at the end of environment, so each row is display in a newpage, as you ask.

\documentclass{article}
\usepackage[showframe,paperwidth=32cm]{geometry}
\usepackage{hyperref}
\usepackage{datatool}
\begin{document}
\centering
\null
\vspace{\fill}
\begin{tabular}{*{5}{c}}
\bfseries Id & \bfseries Institute & \bfseries Address & \bfseries Degree & \bfseries Web \\
\id & \instit & \addr & \degr & \web
\end{tabular}

\vspace{\fill}
\begin{tabular}{*{6}{c}}
\bfseries Fee & \bfseries Application fee & \bfseries Application dl & \bfseries Start date & \bfseries Duration & \bfseries Contact person\\
\fee & \appl & \appldl & \sdate & \durat & \person
\end{tabular}

\vspace{\fill}
\begin{tabular}{*{4}{c}}
\bfseries Cp title & \bfseries Cp contact & \bfseries Action planned & \bfseries Action taken \\
\cptitle & \cpcontact & \actionp & \actiont
\end{tabular}

\vspace{\fill}
\begin{tabular}{*{3}{c}}
\bfseries Futher action & \bfseries Fadl & \bfseries Last update\\
`