Download csvsimple.
Transcript
/csv/csvsorter token=hfile namei
(no default, initially \jobname.csvtoken)
Sets hfile namei as token file. This is an auxiliary file which communicates the success of
CSV-Sorter to csvsimple.
\csvset{csvsorter log=outdir/\jobname.csvtoken}
Here, the token file is written to a subdirectory named outdir.
/csv/sort by=hfile namei
(style, initially unset)
The hfile namei denotes an XML configuration file for CSV-Sorter. Setting this option
inside \csvreaderÕ P. 7 or \csvloopÕ P. 7 will issue a system call to CSV-Sorter.
• CSV-Sorter uses the given CSV file as input file.
• CSV-Sorter uses hfile namei as configuration file.
• The output CSV file is denoted by /csv/preprocessed fileÕ P. 19 which is by
default \jobname_sorted.csv. This output file is this actual file processed by
\csvreaderÕ P. 7 or \csvloopÕ P. 7 .
• CSV-Sorter also generates a log file denoted by /csv/csvsorter logÕ P. 20 which is
by default csvsorter.log.
First example: To sort our example grade.csv file according to name and givenname, we
use the following XML configuration file. Since CSV-Sorter uses double quotes as default
brackets for column values, we remove bracket recognition to avoid a clash with the escaped
umlauts of the example CSV file.
Configuration file «namesort.xml»
<?xml version="1.0" encoding="UTF-8"?>
<csv>
<bracket empty="true" />
<sortlines>
<column name="name" order="ascending" type="string"/>
<column name="givenname" order="ascending" type="string"/>
</sortlines>
</csv>
% \usepackage{booktabs}
\csvreader[sort by=namesort.xml,
head to column names,
tabular=>{\color{red}}lllll,
table head=\toprule Name & Given Name & Matriculation & Gender & Grade\\\midrule,
table foot=\bottomrule]
{grade.csv}{}{\csvlinetotablerow}
Name
Given Name
Matriculation
Gender
Grade
Bauer
Huber
Maier
Weißbäck
Maria
Anna
Hans
Werner
19202
23456
12345
34567
f
f
m
m
3.3
2.3
1.0
5.0
21