| 1 |
% This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04 |
| 2 |
% Example 100 Sorting CSV Data Using \DTLsortdata by Organisation, Surname and Forename With Replacements |
| 3 |
% Label: "ex:sortcsvrepl" |
| 4 |
% arara: pdflatex |
| 5 |
% arara: pdfcrop |
| 6 |
\documentclass[12pt]{article} |
| 7 |
\pagestyle{empty} |
| 8 |
\begin{filecontents}[noheader,overwrite]{customers.csv} |
| 9 |
Id,Organisation,Surname,Forename,Email,Age |
| 10 |
1,,Parrot,Polly,[email protected],42 |
| 11 |
2,University of Somewhere,Canary,Mabel,[email protected] |
| 12 |
3,University of Somewhere,Zebra,Zoë,[email protected],21 |
| 13 |
4,Zinnia Florestry,Arara,José,[email protected],42 |
| 14 |
5,,Duck,Dickie,[email protected], |
| 15 |
6,Newt Fellowship,Axolotl,Lizzie,[email protected] |
| 16 |
7,Avian Emporium,Canary,Fred,[email protected],19 |
| 17 |
8,Newt Fellowship,,Molgina,[email protected] |
| 18 |
9,,Mander,Sally |
| 19 |
10,Élite Emporium,Fant,Eli,[email protected],101 |
| 20 |
\end{filecontents} |
| 21 |
|
| 22 |
\usepackage{datatool} |
| 23 |
\DTLsetup{store-datum,default-name=customers} |
| 24 |
\DTLread{customers.csv} |
| 25 |
\begin{document} |
| 26 |
\DTLsortdata{customers} |
| 27 |
{ |
| 28 |
Organisation={replacements={Surname,Forename}}, |
| 29 |
Surname={replacements={Forename}}, |
| 30 |
Forename |
| 31 |
} |
| 32 |
|
| 33 |
\DTLaction{display} |
| 34 |
\end{document} |