I’m currently working on a major new version of the datatool package. This may take a while. Please be patient. (Experimental version available for testing.)
|Closed (Not Implemented)
Sign in if you want to like this report.
|DTLiflastrow for conditions in foreach
Sign in to subscribe to notifications about this report.
DescriptionDear Nicola Talbot,
your datatool-package is very great and helps me in a lot of cases (even with big amounts of data). Sometimes I am iterating through a database with the DTLforeach-command and a condition. The condition leaves some rows out, maybe the last.
Is it possible to have a command within foreach, that can decide wether it will be the last row in the loop and not in the database itself? It seems a little bit complicated, because the DTLforeach seems to read the next row of the database every loop iteration and decides then, if the condition matches. Maybe it is possible to store the output of every iteration with a match of the condition in a savebox (e.g. the box in tcolorbox) and print the savebox when datatool knows, what row will be the last one?
Unfortunately I don't think this is possible in general as it would need to look ahead and scan the rest of the database at the end of each iteration to determine if the current row is the last to satisfy the condition, which would be very inefficient. It would be quicker to simply have two loops: the first to determine the final row index and the second to test the current row index against the previously found final row index. It would be even better if the first loop saved a list of the required row indexes and then the second loop iterated over that list (instead of the entire database). An even faster approach would be to use datatooltk to perform the filtering.
Page permalink: https://www.dickimaw-books.com/featuretracker.php?key=39