Hi,
I am generating letter using csvtools package. I have a CSV file which has three fields: Name, address, grade.
I wrote the code, but I want to print a part of text based on condition (data from the CSV file). For example if grade is "A" then print "distincation" for that student, if grade is "B" then print "firstclass" for that student.
Please let me know how can I do this .
Regards
Shagi
General ⇒ csvtools | Print Text based on Condition
NEW: TikZ book now 40% off at Amazon.com for a short time.

csvtools | Print Text based on Condition
csvtools is obsolete and has been replaced by datatool. Here's a minimal example:
Regards
Nicola Talbot
Code: Select all
\documentclass{letter}
\usepackage{etoolbox}
\usepackage{datatool}
\begin{filecontents*}{test.csv}
Name,Address,Grade
A.N. Other,1 The Street,A
Some One,2 The Road,B
\end{filecontents*}
\DTLloaddb{mydata}{test.csv}
\newcommand{\Agrade}{distinction}
\newcommand{\Bgrade}{first class}
\newcommand{\gradelabel}[1]{%
\ifcsdef{#1grade}{\csuse{#1grade}}{unknown classification}%
}
\begin{document}
\DTLforeach*{mydata}{\Name=Name,\Address=Address,\Grade=Grade}{%
\begin{letter}{\Name\\\Address}
\opening{Dear \Name}
You grade is \Grade\ (\gradelabel{\Grade}).
\end{letter}
}
\end{document}
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/