5

With the latest version of the datatool package, if I compile this file

\begin{filecontents*}{\jobname.csv}
  x,y
  11,12
\end{filecontents*}

\documentclass{article}
\usepackage{datatool}
\DTLloaddb{table}{\jobname.csv}

\begin{document}

\end{document}

I get this error

./example.tex:9: LaTeX Error: Missing \begin{document}.

In the pdf file it appears

,12

If I substitute 11 for 22 or 33 or ... I get the same error, but if I use any other number it compiles fine.

The file list is this

*File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
datatool.sty    2017/11/10 v2.28 (NLCT)
 xkeyval.sty    2014/12/03 v2.7a package option processing (HA)
 xkeyval.tex    2014/12/03 v2.7a key=value parser (HA)
  ifthen.sty    2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
    xfor.sty    2009/02/05 v1.05 (NLCT)
  substr.sty    2009/10/20 v1.2 Handle substrings
etoolbox.sty    2017/01/02 v2.4 e-TeX tools for LaTeX (JAW)
datatool-base.sty    2017/11/10 v2.28 (NLCT)
 amsmath.sty    2017/09/02 v2.17a AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
datatool-fp.sty    2017/11/10 v2.28 (NLCT)
      fp.sty    1995/04/02
defpattern.sty    1994/10/12
fp-basic.sty    1996/05/13
fp-addons.sty    1995/03/15
 fp-snap.sty    1995/04/05
  fp-exp.sty    1995/04/03
fp-trigo.sty    1995/04/14
  fp-pas.sty    1994/08/29
fp-random.sty    1995/02/23
  fp-eqn.sty    1995/04/03
  fp-upn.sty    1996/10/21
 fp-eval.sty    1995/04/03
2
  • ping Nicola \dtl@trim #1->\def \@dtl@trmstr {}\if #1\par \else \expandafter \@dtl@start@tri probably shouldn't be using \if Nov 12, 2017 at 11:35
  • excellent test file thanks (+1), especially with the information about the problem applying only to repeated digits, that meant it was almost certain to be a rogue \if so it was just a matter of tracing to find which \if was causing the problem. Nov 12, 2017 at 11:55

2 Answers 2

3

It's a bug in the last update to the package but I think a workaround is

\begin{filecontents*}{\jobname.csv}
  x,y
  11,12
\end{filecontents*}

\documentclass{article}
\usepackage{datatool}

\makeatletter
\def\dtl@trim#1{\def\@dtl@trmstr{}%
\if \par#1 \else \expandafter \@dtl@start@trim #1\@dtl@end@trim \fi
\let#1=\@dtl@trmstr}

\makeatother

\DTLloaddb{table}{\jobname.csv}

\begin{document}

\end{document}
8
2

Fixed in v2.29 (2017-11-12). I've changed the way lines are read and trimmed. The code now locally changes \endlinechar to \active which makes it much simpler to trim the end of line character. Unlike spaces, there should only be one end of line character in the control sequence, and it will be at the end. (As documented, datatool doesn't support multiline CSV files. You need datatooltk for that.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .