I'm using the package "snapshot" to generate a list of external dependencies of my filename.tex file. This list's result is stored in a filename.dep file.
The goal would be to use this filename.dep file, to extract some interesting data, and to make this data available in my filename.tex file.
The filename.dep file looks like this:
\RequireVersions{
*{text #1 of variable length} {text #2 of variable length} {text #3 of variable length}
}
with 2 blanks in front of *, and some different spacings between the {} {}.
The interesting data for me is text #2, but only for some values of text #1. Text #3 isn't useful for me. I would like to call a command in my filename.tex file, for example
\generate_useful_dependancies[criteria on text #1]{filename}
which outputs the list of all #2 texts written in filename.dep file.
Here is the starting point, my filename.tex file (MNWE). I'm creating between \begin{filecontents} and \end{filecontents} what should be read by the command loaddata (which in the end should become my \generate_useful_dependancies command). Then next lines is what interest me.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{filename.dep}
\RequireVersions{
*{file} {mem10.clo} {2022/07/29 v0.5}
}
\end{filecontents*}
\makeatletter
\newread\myread
\def\loaddata#1{%
\def\linetomatch{Line with bar}% \edef is not required
\openin\myread=#1
\begingroup\endlinechar=-1
\@whilesw\unless\ifeof\myread\fi{%
\read\myread to \dataline
\noindent"\linetomatch"
\ifx\dataline\linetomatch\relax
equals
\else
does not equal
\fi
"\dataline"\par
}%
\endgroup
\closein\myread
}%
\makeatother
\begin{document}
\loaddata{filename.dep}
\end{document}
The problems are:
- the first line is not correctly read because of the \ character
- the last one also, probably because of }
- then, I do not know how to read the second line in order to have text #1 and text #2.
Could someone give me some hints?