# Omit repeated values in CSV file with csvsimple

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?

COUNTRY,INST,ADDR,PHONE
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:

\subsubsection{US}
Dept of Justice: Washington DC\\Phone 123-456/7890\par
Dept of Education: Seattle WA\\Phone 234-567/8910\par
\subsubsection{UK}
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.

\documentclass{article}
\usepackage{ifthen}
\usepackage{csvsimple}
\newcommand\COUNTRYlast{}
{\ifthenelse{\equal{\COUNTRY}{\COUNTRYlast}}%
{}%
{\subsubsection{\COUNTRY}%
\edef\COUNTRYlast{\COUNTRY}%
}%