3

I am trying to operator on a CSV file on a row-by-row basis with the following dummy code.

\documentclass{article}

\usepackage{datatool}
\usepackage{filecontents}

\begin{filecontents*}{data.csv}
x,y
-10,2.43653438865896e-13
-9.59183673469388,4.78477532813286e-12
-9.18367346938776,7.9563926658023e-11
-8.77551020408163,1.12012542586698e-09
-8.36734693877551,1.33501414606147e-08
-7.95918367346939,1.34698479017595e-07
-7.55102040816327,1.15051489663322e-06
-7.14285714285714,8.31902240126465e-06
-6.73469387755102,5.09215716998077e-05
\end{filecontents*}

\begin{document}
    \DTLloaddb{table}{data.csv} 
    %
    \DTLforeach*{table}{%
        \xx=x,%
        \yy=y,%
    }{}%
\end{document}%  

Which gives me

File ended while scanning use of \@dtl@next.

What is wrong with this code?

P.S.: I am using lualatex on TL2018.

3

There's a spurious comma at the end of the second argument of \DTLforeach:

\DTLforeach*{table}{%
    \xx=x,%
    \yy=y,% <-- here
}{}%

(Empty elements aren't skipped by the parser.) Just remove it:

\DTLforeach*{table}{%
    \xx=x,%
    \yy=y%
}{}%
  • Ohh dear....I have wasted hours on that! You've got eagle eyes ;-) Thanks so much. – bonanza Nov 8 '18 at 21:27

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.