This question led to a new feature in a package:
datatool
Update: 2013-1-19
The MWE worked fines with the new (v2.13) version of the datatool package using \DTLnewdbonloadfalse. But in my actual usage I am getting the message:
Runaway argument? \db@plist@elt@w \db@col@id@w 1\db@col@id@end@ \db@key@id@w Chapter\db@key@id@end@ \ETC.
! File ended while scanning use of \@dtl@get@keydata.
after approximately 16172 DB \DTLloaddb -- approximate as I am only counting the DB's that are repeatedly loaded.
Will try to create a MWE for this, but in case it is obvious to someone else what the problem is I thought I'd add this information while I try to get to the bottom of this.
Background:
I am generating a document which tracks the progress on components of a project consisting of a large number of files. For each of these files, a tiny DB is generated and read via the datatool package. This DB contains a list of the related files and and where they were found, and what types of files they were.
Although this is not related to the MWE below, here is a small excerpt from the output to illustrate what I am actually trying to achieve:

from which I can tell that file
- 15-4-34 has some progress (shown in blue text)
- 15-4-35 and 15-4-36 has significant progress (highlighted).
- 15-4-37 has had no progress at all (shown in red)
Each of these are links to the files so I can just click on them to open them to view, and I can tell which team member has made progress. At the end of the document I produce a summary report so I know how far along I am into the project. There is a bunch of other info that is captured as well, but this should be sufficient to give an idea as to the actual use case.
The list of associated files is contained in two small CSV files that are generated at run time, for each component of the project. For instance, if a .tex file exists, I would then check that there was a corresponding PDF, and if any associated figures were completed, or if there was a \todonote in the .tex file which indicated that that this file was still not complete, etc..
Problem:
While processing this document, I received the following error message:
No room for a new \count .\et@xchk ...lse \errmessage {No room for a new #2}
As per egreg's answer at the first reference listed below, three are two potential causes for this:
- Too many packages
- A programming error, such as saying
\newdimeninside the definition of a command.
After thoroughly searching my code for such programming errors, I determined that the culprit is the datatool package which declares a \newcount within \DTLnewdb:
\newcommand*{\DTLnewdb}[1]{%
\DTLifdbexists{#1}%
{%
\PackageError{datatool}{Database `#1' already exists}{}%
}%
{%
\dtl@message{Creating database `#1'}%
\expandafter\newtoks\csname dtldb@#1\endcsname
\expandafter\newtoks\csname dtlkeys@#1\endcsname{}%
\expandafter\newcount\csname dtlrows@#1\endcsname
\expandafter\newcount\csname dtlcols@#1\endcsname
}%
}
It appears to release these in \DTLdeletedb as follows:
\expandafter\let\csname dtlrows@#1\endcsname\undefined
\expandafter\let\csname dtlcols@#1\endcsname\undefined
However, it appears that this is not really having the desired effect of returning the counter back to the available list of counters for subsequent use as the MWE illustrates.
Notes:
- The MWE needs the file
MyData.csv. However, I commented out\usepackage{filecontents}to prevent overwriting of this file to prevent accidental deletion. - The output of the MWE below is not important, just there so a PDF gets created.
Question:
- Is there a workaround for this, or perhaps a better way of using the
datatoolpacakge for such a thing?
References:
Code:
\documentclass{article}
\usepackage{datatool}
\usepackage{pgffor}
%\usepackage{filecontents}% Commented to prevent overwriting MyData.csv
\begin{filecontents*}{MyData.csv}
Directory, Color
../dirB, red
../dirC, yellow
\end{filecontents*}
\begin{document}
\foreach \x in {1,...,10000} {% Read DB numerous times
\DTLifdbexists{MyDB}{\DTLdeletedb{MyDB}}{}%
\DTLloadrawdb[keys={Directory,Color}]{MyDB}{MyData.csv}%
}%
\par\noindent\DTLdisplaydb{MyDB}% Some output to have a PDF
\foreach \x in {1,...,10000} {% Read DB numerous times
\typeout{count=\x}%
\DTLifdbexists{MyDB}{\DTLdeletedb{MyDB}}{}%
\DTLloadrawdb[keys={Directory,Color}]{MyDB}{MyData.csv}%
}%
\end{document}