# How to make uppercase letter from data reads from .csv file using datatool?

I want to make the data from \g to be converted to uppercase letter then I want to use that data for comparison commands like \IfStrEq{\g}{F}{}{} because in \g it may contain f or F; if it contains f then make it uppercase letter, \MakeUppercase command is not working inside \IfStrEq. Here is my MWE:

 \documentclass[10.0pt,legalpaper,landscape]{article}
\usepackage[top=0.5cm,bottom=1.4cm,left=2cm,right=0.1cm]{geometry}
\usepackage[table]{xcolor}
\usepackage[all]{tcolorbox}
\usepackage{filecontents}
\usepackage[english]{babel}
\usepackage{graphicx,booktabs,xstring,datatool,xintexpr,longtable,minted} %for including eps graphics
\usepackage{multirow,colortbl}
\usepackage{ifthen}
\newboolean{long}

\renewcommand{\dtldisplaystarttab}{\toprule}
\renewcommand{\dtldisplayendtab}{\\\bottomrule}

\begin{filecontents*}{test.csv}
Name,Gender,Blood Group
Mr. A,f,A+
Mr B,m,AB-
Mr. C,f,O+
Mr D,M,AB-
Mr. E,F,O+
Mr. F,F,O+
Mr. G,F,O+
\end{filecontents*}
\newcounter{Female}
\newcounter{Male}
\newcounter{Total}

\begin{document}
\begin{longtable}{|c|l|c|c|}
\hline
Sl. No. & Name & Gender & Blood Group

\DTLforeach*{name}{\name=Name,\b=Blood Group,\g=Gender}{%

\IfStrEq{\MakeUppercase{\g}}{F}{\stepcounter{Female}\\\hline \theFemale & \name & \b & \g }{}

}\\\hline

&&\MakeUppercase{latex}&

\end{longtable}
\centering
\MakeUppercase{latex}

\end{document}

• Well, you try to expand a non-expandable command. Have a look at this question, which solves that. – TeXnician May 20 '17 at 6:53
• what is expand a non-expandable command kindly please let me know more about? @TeXnician – Biki Teron May 20 '17 at 6:57
• A quick search leads to this. – TeXnician May 20 '17 at 6:58
• Can you please give me more information on macro term used in latex? @TeXnician – Biki Teron May 20 '17 at 7:02

Test whether the gender is a sub-string of f,F instead:

\documentclass{article}

\usepackage{filecontents}
\usepackage{xstring,datatool}

\begin{filecontents*}{test.csv}
Name,Gender,Blood Group
Mr. A,f,A+
Mr B,m,AB-
Mr. C,f,O+
Mr D,M,AB-
Mr. E,F,O+
Mr. F,F,O+
Mr. G,F,O+
\end{filecontents*}

\newcounter{Female}

\begin{document}

\begin{tabular}{|c|l|c|c|}
\hline
Sl. No. & Name & Gender & Blood Group
\DTLforeach*{name}{\name=Name,\b=Blood Group,\g=Gender}{%
\IfSubStr{f,F}{\g}{\stepcounter{Female}%
\\
\hline \theFemale & \name & \b & \g }{}
}\\
\hline
\end{tabular}

\end{document}


\MakeUppercase{\g} is not expandable in the comparison, meaning it doesn't turn \g into its uppercase equivalent until much later. Since you're dealing with a very specific set of possibilities, \IfSubStr can work were the options are separated with some other character.