| 1 |
% This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04 |
| 2 |
% Example 113 Automatically Reformatting Data While Loading a CSV file |
| 3 |
% Label: "ex:auto-reformat-csv" |
| 4 |
% arara: pdflatex |
| 5 |
% arara: pdfcrop |
| 6 |
\documentclass[12pt]{article} |
| 7 |
\pagestyle{empty} |
| 8 |
\usepackage{scontents}% to write test file with TABs preserved |
| 9 |
\begin{scontents}[write-out={profits.csv},overwrite] |
| 10 |
Year,Profit,Units |
| 11 |
1999,"-\$4,673",12467 |
| 12 |
2000,"\$2,525.49",8965 |
| 13 |
2001,"\$1,673.52",14750 |
| 14 |
2002,"-\$1,320.01",14572 |
| 15 |
2003,"\$5,694.83",13312 |
| 16 |
2004,"\$-451.67",9764 |
| 17 |
2005,"\$6,785.20",11235 |
| 18 |
\end{scontents} |
| 19 |
|
| 20 |
% This document additionally required datatool-english and datatool-regions to be installed |
| 21 |
\usepackage[locales={en-US}]{datatool} |
| 22 |
\DTLsetup{store-datum,default-name=profits} |
| 23 |
\DTLread[ |
| 24 |
format=csv, |
| 25 |
csv-content=tex, |
| 26 |
only-reformat-columns={2,3}, |
| 27 |
]{profits.csv} |
| 28 |
\DTLsetLocaleOptions{US}{currency-symbol-sep=thin-space} |
| 29 |
\begin{document} |
| 30 |
\DTLaction{display} |
| 31 |
\end{document} |