Assume I have a directory which has a dynamic number of files match a certain pattern (e.g. tabledata0.csv, tabledata1.csv). Now I want to create automatically create tables out of it. Sometimes it is 1 table, sometimes 2, etc.

Now for each file matching pattern I want to load the data and create a table. Also I want to track a counter, so.

Is it possible to do the loop with foundfile and nr in the construction below?

Alternatively it is also fine if this cannot be done on pattern but for all files in a directory.

<For each foundfile,nr matching pattern tableData*.csv>
\caption{My table caption (<nr>)}

Here is a solution based on \IfFileExists{}{}{}

\foreach not necessary just to make it easy

\foreach \x in {1,...,10} {%
\caption{My table caption (\x)}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.