I'm super new to Latex and I'm trying to do automatic documents that present information regarding each project. Every folder and project has a different name/code and I'd like the document to add a table from a csv file that has the same code and is present in the same folder.

The code for the csv file would be something like XX.000000000.XX.V00.csv, and I need the 0's to be different for each project (I'm trying to take them from the name of project with several concatenations). I can't get the csv reader to use the variable as a filename. How can I solve this? Below is my code.


\csvautotabular[separator=semicolon, respect all]{\csvfilename}

Thanks in advance for your help!

1 Answer 1


Your \g@addto@macro\csvfilename{\substring{\currfilename}{4}{12}} doesn't work. Instead of adding the required substring, it literally adds the text \substring{followed by the original filename, followed by the literal text {4}{12}, etc.

The reason is that \substring is not expandable. Instead it writes its result in a macro \thestring. Therefore the solution for creating the filename is instead of all the \g@addto@macros:


To find out what the filename has become, use

This is the filename: \texttt{\meaning\csvfilename}
  • Thanks for taking the time to help out. I copied your solution and inserted the filename in the \csvautotabular and got this outcome: linkpicture.com/q/img_1.png Feb 9, 2021 at 16:07
  • That means \csvfilename is empty. What is your \currfilename? Can you post the whole LaTeX file? Feb 9, 2021 at 19:27
  • Hi, thanks for your help. I don't think \csvfilename is empty because it writes to the file. Here is the document: we.tl/t-gtpAXo1PSm Feb 10, 2021 at 12:23
  • You shouldn't use \csvautotabular[separator=semicolon, respect all]{\texttt{\csvfilename}} but \csvautotabular[separator=semicolon, respect all]{\csvfilename}. The \texttt{}` ruins the filename given to the command. Feb 10, 2021 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .