i have following MWE. For the first case with test.csv works my code very fine for the second dataset test_data.csv crashes the compiler with:
[cmd]
! Missing $ inserted.
<inserted text>
$
l.52 OK: \csvval{test_
data.csv}{1,1} % fail caused by '_' in file name
?
[/cmd]
Code: Select all
Code, edit and compile here:
\documentclass[fontsize=12pt,% changed because of the package info in the log fileDIV=14]{scrreprt}\usepackage[english]{babel}\usepackage{readarray}\usepackage{xifthen}% https://tex.stackexchange.com/questions/562789/how-to-look-up-a-cell-value-of-a-multi-column-csv-file% https://latex.org/forum/viewtopic.php?f=5&t=34743% \csvval[<separator>]{file.csv}{row,column}\newcommand{\csvval}[3][]{%% https://stackoverflow.com/questions/2144176/latex-newcommand-default-argument-is-empty\ifthenelse{\isempty{#1}} {%default separator\readarraysepchar{,}%} {% else\readarraysepchar{#1}%}%\readdef{#2}\csvvaldata%\readarray\csvvaldata\csvvalarray[-,\ncols]%\arraytomacro\csvvalarray[#3]\csvval%}\begin{document}\begin{filecontents*}{test_data.csv}val11; 0.1val21; 0.5val31; 5e-3val41; 22\end{filecontents*}\begin{filecontents*}{test.csv}val11; 0.1val21; 0.5val31; 5e-3val41; 22
Thanks for your help!
BR,
Andreas