% This file is embedded in datatool-user.pdf version 3.4.1 2025-04-25
% Example 52 Formatting CSV Lists
% Label: "ex:formatlist"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{datatool-base} 
\begin{document}
\renewcommand{\DTLlistformatitem}[1]{\emph{#1}}
One: \DTLformatlist{elephant}. 

Two: \DTLformatlist{elephant,ant}. 

Three: \DTLformatlist{elephant,ant,zebra}. 

Four: \DTLformatlist{elephant,ant,zebra,duck}. 

\renewcommand{\DTLlistformatoxford}{,}
Oxford comma: \DTLformatlist{elephant,ant,zebra,duck}. 

Omit empty elements and leading/trailing spaces:
\DTLformatlist{elephant , ant,,duck}. 

\DTLsetup{ 
 lists = { trim = false, skip-empty = false } 
}
Retain empty elements and leading/trailing spaces:
\DTLformatlist{elephant , ant,,duck}. 
\end{document}
