I have a quite complex C program that has the ability to generat raw text output to text files that are then printed on a matrix printer. These lists are now meant to receive a typographical update to finally exist as a PDF that can be printed on a regular laser printer. For this I intend to use LaTeX. I can not exchange the C program, only modify the "printing/text output" functionality.
The general layout of the document to be generated is well-defined, but the number of rows of data is not.
So, in a first step I wrote a LaTeX "template" file, like this:
\documentclass{article}
\begin{document}
Dear --MRMRS-- --NAME--, we hope ...
And let my program replace (in the end with a sed 's/KEYWORD/programoutput/' command) the keywords --MRMRS--, --NAME-- by the data it produces in raw form. This works pretty well, to this point. As already mentioned, the length of some parts of the generated files is not clear beforehand. For example, later in the document there will be tables with a well-defined structure, but these tables can be different in length each time, so I can not simply define a given Number of --ROWxCOLy-- beforehand:
\begin{tabular}{cccc}
Col1 & Col2 & Col3 & Col4 \\
\hrule
% now how to fill the content sequentially without knowing the size beforehand?
\end{tabular}
Thank your, we hope to hear from you on --DATE-- ...
\end{document}
The data that comes looks currently like
Col1 Col2 Col3 Col4
Col1 Col2 Col3 Col4
Col1 Col2 Col3 Col4
COLSPANNED LINE
Col1 Col2 Col3 Col4
Col1 Col2 Col3 Col4
... variable amount of lines
There can be special lines that need a full column span (span whole width)
but they come in well-defined order
The first solution that comes to mind is to hardcode LateX code directly in the data generating program, to have one keyword for the whole table, that is then generated with hardcoded LaTeX code in the program. But I'd like to avoid this as much as possible for obvious maintainance reasons (keep layout and logic separated as much as possible).
What other possible solutions are there to feed a LaTeX document with well-defined, but unknown length data?