1

MWE (actually not totally MWE, but I think it's easier to see what happens this way):

\documentclass{article}
\usepackage{csvsimple}
\usepackage{graphicx}

\begin{document}
\setlength\unitlength{1cm}

\csvreader[head to column names]{jobname2.csv}{}{%
\vfill
\artist

\includegraphics[height=37mm]{\filenameone}

\includegraphics[height=37mm]{\filenametwo}

\comment
}
\end{document}

Content of jobname2.csv:

artist,filenameone,filenametwo,comment
Foo,example-image-a,example-image-b,Nothing
Foobar,example-image-a,,Something

When there is nothing in the filenametwo column, I don't want anything done (not sure how to express that properly).

2

csvsimple provides a macro \ifcsvstrequal{X}{Y}{equal}{not equal} to conditionally execute code if the two parameters X and Y are equal or not (basically an \ifx of two \edef-ed token lists). You can use that macro in your example without the need for extra packages like xstring:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.csv}
artist,filenameone,filenametwo,comment
Foo,example-image-a,example-image-b,Nothing
Foobar,example-image-a,,Something
Bar,,example-image-b,Anything
\end{filecontents*}

\usepackage{csvsimple}
\usepackage{graphicx}

\begin{document}
\setlength\unitlength{1cm}

\csvreader[head to column names]{\jobname.csv}{}{%
\vfill
\artist

\ifcsvstrequal{\filenameone}{}{(no first image)}{%
    \includegraphics[height=37mm]{\filenameone}
}
\ifcsvstrequal{\filenametwo}{}{(no second image)}{%
    \includegraphics[height=37mm]{\filenametwo}
}

\comment
}
\end{document}

enter image description here

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.