4

I wish to read a CSV file that has special characters in the headers. While I got what the documentation says about special characters in the body of the file, I couldn't get it to work for the column headers.

For example the file foobar.csv containing

cliché, foo
10,20

Can't be read by \DTLloaddb{foobar.csv}, though, presenting the following error message

Missing \endcsname inserted. \DTLloaddb{foobar}{foobar.csv}

While the same file exchanging cliché for cliche compiles flawlessly.

Thanks in advance for any help.


Minimum working example:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents*}{sample}
cliché
10
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb{sample}{sample}
\begin{document}
\DTLdisplaydb{sample}
\end{document}

Won't work with cliché, does work with cliche.

  • 1
    Could you please provide a complete minimal working example, beginning at \documentclass and ending at \end{document}? For the csv you might use filecontents. – Skillmon likes topanswers.xyz May 10 '17 at 17:07
4

Without specifying any <options>, both the header text and the key associated with that field/column is given the name in the header, and you can't have \cliché as the header key. So, specify a separate set of keys for the header:

enter image description here

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{filecontents,datatool}

\begin{filecontents*}{foo.csv}
cliché, foo
10,20
\end{filecontents*}

\DTLloaddb[keys={cliche,foo}]{foo}{foo.csv}

\begin{document}

\DTLdisplaydb{foo}

\end{document}
| improve this answer | |
  • That is super helpful. Thank you very much! – Vinicius Godim May 10 '17 at 17:38

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.