Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example067.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 67 Select row action
3 % Label: "ex:selectrow"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 % sample CSV file:
9 \begin{filecontents}[noheader,overwrite]{studentmarks.csv}
10 Surname,Forename,StudentNo,Assign1,Assign2,Assign3
11 "Smith, Jr",John,102689,68,57,72
12 "Brown",Jane,102647,75,84,80
13 "Brown",Jane,102646,64,92,79
14 "Brown",Andy,103569,42,52,54
15 "Adams",Zoƫ,105987,52,48,57
16 "Brady",Roger,106872,68,60,62
17 "Verdon",Clare,104356,45,50,48
18 \end{filecontents}
19
20
21 \usepackage{datatool}
22
23
24 % Load data from studentmarks.csv file:
25 \DTLsetup{store-datum,default-name=marks}
26 \DTLread{studentmarks.csv}
27 \begin{document}
28 Row selection:
29
30 \DTLaction[
31 name=marks,
32 key=StudentNo,
33 value={105987}
34 ]{select row}
35
36 Student \DTLuse{Forename} \DTLuse{Surname} (105987).
37
38 \DTLaction[
39 keys={Assign1-},
40 options={mean},
41 datum={round=1}
42 ]{current row aggregate}
43
44 Average mark: \DTLuse{mean}.
45
46
47 (Actual value: \DTLget[mean]{\theMean} \DTLdatumvalue{\theMean}.)
48 \end{document}