I want to use the csvsimple package to turn a CSV file into a set of paragraphs, using the value of column 1 as a subsubsection header.

I can't see from the documentation any way to do an action only on first occurrence of a value. Is this possible with csvsimple?

US,Dept of Justice,Washington DC,123-456/7890
US,Dept of Education,Seattle WA,234-567/8910
UK,Minitrue,London WC,123 456 7890
UK,Miniluv,London EC,234 567 8910

This should generate something like:

Dept of Justice: Washington DC\\Phone 123-456/7890\par
Dept of Education: Seattle WA\\Phone 234-567/8910\par
Minitrue: London WC\\Phone 123 456 7890\par
Miniluv: London EC\\Phone 234 567 8910\par

Is this possible? I was hoping to avoid the complexity of the datatool package, wonderful though it is.


When processing the data you can test whether \COUNTRY has changed, e.g. with the ifthen package. address.csv is your sample data.

   \INST: \ADDR\\Phone \PHONE\par

\parskip3pt plus1pt minus 1pt

\csvreader[head to column names]{address.csv}{}{\doaddress}

results in

enter image description here

  • Indeed I can; many thanks for the example. This mechanism would be a good enhancement... – Peter Flynn Oct 31 '16 at 15:54

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.