# \ifnum for datatool package

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}
Maier,Hans,12345,m,1.0
Huber,Anna,23456,f,2.3
Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}

\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}


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

• 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
• @ChrisPeh: No, it's not. You can just use \DTLsavelastrowcount{\CounterI} directly. – Werner Jan 6 at 4:24