# Auto generate list-items within table from string with delimiter

This is a follow-up on this question: Creating bullet-list from string with delimiters

I have a CSV file where I genereate some tables from. Some of those table cells will have items that should be itemized.

MWE:

\documentclass{scrreprt}
\usepackage{csvsimple}
\usepackage{etoolbox}
\DeclareListParser{\ListParser}{|}
\newcommand{\listItems}[1]{
\parbox{10cm}{
\begin{itemize}
\newcommand*{\do}[1]{\item[] ##1}
\expandafter\ListParser\expandafter{#1}
\ListParser{#1}
\end{itemize}
}
}
\begin{document}
\begin{table}
\begin{tabular}{|l|l|}
\hline
Name     & \ucname \\ \hline
Trigger  & \listItems{\trigger} \\ \hline
\end{tabular}
\end{table}
}
\end{document}


CSV Example:

ucname,trigger
test,This is|A test
test2,Barely
test3,No List
test4,List|Again|Here


However, this current code gives me the output of the whole string of \trigger twice, and not delimited.

You need to expand the list you process twice and only process the list once:

\documentclass{scrreprt}
\usepackage{filecontents}
\begin{filecontents*}{usecases.csv}
ucname,trigger
test,This is|A test
test2,Barely
test3,No List
test4,List|Again|Here
\end{filecontents*}

\usepackage{csvsimple}
\usepackage{etoolbox}
\DeclareListParser{\ListParser}{|}
\newcommand{\listItems}[1]{%
\parbox{10cm}{%
\begin{itemize}%
\renewcommand{\do}[1]{\item[] ##1}
\expandafter\expandafter\expandafter\ListParser\expandafter\expandafter\expandafter{#1}
\end{itemize}%
}%
}
\begin{document}
\begin{table}
\begin{tabular}{|l|l|}
\hline
Name     & \ucname \\ \hline
Trigger  & \listItems{\trigger} \\ \hline
\end{tabular}
\end{table}
}
\end{document}


• Thanks for explaining this. Why didn't you get bullet points in your itemize list? – Andrew Aug 12 '14 at 23:48
• @Andrew: The OP uses \item[] which nullifies the bullet. – Werner Aug 13 '14 at 0:11
• Yeah, thanks, I realised this when I was getting a coffee... Clearly needed it:) – Andrew Aug 13 '14 at 0:53
• Hmm, I can't really get it to work properly.. If I type exactly what you posted I get this error: Something's wrong--perhaps a missing \item. }.. Adding back in \ListParser{#1} makes it compile and spit it out both right and wrong at the same time.. (Both the separated string and the complete string as separate bulletpoints) – Frederik Nielsen Aug 13 '14 at 17:00
• @FrederikNielsen: First of all, you only need one \ListParser command. You probably have two. Make sure that this is the case. I see two in your code snippet in the post. – Werner Aug 13 '14 at 17:05