I constantly receive an updated file (year.csv) which should be sorted as shown below.
But only the first 10 rows (after sorting) should be shown.
The MWE works and I can omit all rows with DTLrowi larger than 10, but the rows are still there.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{year.csv}
1984|1
1998|1
1999|2
2001|2
2002|2
2003|1
2004|2
2005|20
2006|42
2007|64
2008|90
2009|122
2010|130
2011|149
2012|164
2013|123
2014|184
2015|216
2016|204
2017|185
2018|219
2019|190
2020|25
\end{filecontents*}
\usepackage{booktabs}
\usepackage{datatool}
\DTLsetseparator{|}
\DTLloaddb[noheader,keys={year,quantity}]{year}{year.csv}
\DTLsort{quantity=descending}{year}
\begin{document}
\begin{tabular}{ll}
Year & Quantity
\DTLforeach*{year}
{\year=year,%
\quantity=quantity}
{
\\\ifnum\value{DTLrowi}>10
\DTLremovecurrentrow % <<<< ?!?!?!??!!? error
\else
\year & \quantity\fi
}
\\\bottomrule
\end{tabular}
\end{document}
Adding \DTLremovecurrentrow as conditional leads to an error and the log says
! Package datatool Error: \DTLreplaceentryforrow can't be used inside \DTLforeach*.
But in the documentation page 75 it says
The following commands may be used in the body of the \DTLforeach loop,3 to edit the current row of the loop.



