Is it possible to read a number from data files?
How to read a file with luatex
I found the example above but I don't need the whole line at once.
I need somthing like:
read(file)
get(A)
get(B)
X=A+B
print(X)
Sorry for my bad English. :)
Here is my example but it doesnt work :/
\documentclass{scrartcl}
\usepackage{luatextra}
\usepackage{filecontents}
\begin{luacode}
function addplot()
filename = "testdata.dat"
tex.print('\\addplot coordinates {')
for line in io.lines(filename) do
local tab = string.explode(line)
x=tab[1]
y=math.log10(tab[2])
tex.print('('..x..','..y..')')
end
tex.print('};')
end
\end{luacode}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\directlua{addplot()}
\end{axis}
\end{tikzpicture}
\end{document}
Removing the \\ doesnt work.

readarraypackage reads files and allows recall of individual data entries from the file. – Steven B. Segletes Apr 22 '13 at 15:52