# Datatool can't evaluate email as empty?

Given a test.csv file w/ the content:

"BILL TO EMAIL"
"test@att.net"
""
"test.test@test.org"
"test.test@test.org"


Processing it w/ datatool in xelatex w/:

\documentclass{memoir}
\usepackage{datatool}
\begin{document}
\DTLforeach*{data}{\billtoEM=BILL TO EMAIL}{\billtoEM"\DTLifnull{\billtoEM}{N}{Y}"\par}
\end{document}


results in:

How do I get the test to evaluate to N for the second record?

There's a difference between null and empty values (in a similar way to programming languages "" != null). If you load data from a CSV file, missing values are empty. (There is a blank value in that column for that row.) Null values can occur when constructing a database where values for a column or columns aren't assigned. (For example, defining data using \DTLnewdb or pulling data from SQL using datatooltk.)

You can test for empty values using etoolbox's \ifdefempty:

\documentclass{memoir}
\usepackage{datatool}

Alternatively you can use \DTLifnullorempty that tests for null or empty values.
Further details in 5.5 "Null Values" of the datatool user manual.
• @WillAdams That's okay. It's quite a common mistake. I ought to add it to the datatool faq. Nov 24 '15 at 17:49