1

I'm trying to write quotes and depending on "males" selected, it needs to change the output. Unfortunately, in the example below it gives me 2skip although it should give me 2males. What am I doing wrong?


\usepackage{datatool}

\begin{filecontents*}{excel.csv}
included,givenname,matriculation,gender,grade
Maier,Hans,12345,m,1.0
Huber,Anna,23456,f,2.3
Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}

\DTLloaddb{CounterO}{excel.csv}

\begin{document}

\begin{tabular}{lccc}
\DTLforeach*[\DTLiseq{\gn}{m}]{CounterO}%
    {\gn=gender}
    {%
        \DTLiffirstrow{}{\\}
    } 
\end{tabular}

\newcommand{\CounterA}{\DTLsavelastrowcount{\CounterI{}}}
\CounterA
\ifnum \CounterA > 1
males
\else
    \ifnum \CounterA = 1
    male
    \else
    skip
    \fi
\fi

\end{document}
0

Your test needs to be against \CounterI, not \CounterA:

% ...
\newcommand{\CounterA}{\DTLsavelastrowcount{\CounterI}}
\CounterA
\CounterI\space
\ifnum\CounterI=0
  skip%
\else
  male\ifnum\CounterI>1 s\fi
\fi
2
  • It works :) - thank you, but I'm confused that \CounterA doesn't give a value anymore. Is the line of putting the value onto \CounterA necessary then? – Chris Peh Jan 6 at 4:08
  • 1
    @ChrisPeh: No, it's not. You can just use \DTLsavelastrowcount{\CounterI} directly. – Werner Jan 6 at 4:24

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.