Numbers in text, without having to update values from external files by hand?

I am writing a paper discussing numerical results of simulations. I am still tuning those simulations itself, so the results keep changing slightly. I don't want to re-type numbers over from what I computed all the time into the LaTeX document by hand.

I am currently using python to extract results and spit it out files in LaTeX format which are then \include'd (tabulars with numbers, basically), but this approach is not very flexible -- in particular, I can't refer to those numbers in running text.

Is there a packaged way to have e.g. text file with name value lines and then refer to value using \name in LaTeX, or something similar?

-
If you're scripting your output into LaTeX tabular code, rather use \input. Perhaps the datatool package could be of help here. It allows you to read data from a CSV file and perform operations/tests on the database entries. – Werner Oct 27 '11 at 8:13

Tell your Python script to write lines

\def\name{value}%


name value


to your data files to be \input{}ed. Then \name in your main document will expand to the current value. However, with this approach the control sequence name may only contain letters. For general cs names, such as letters mixed with numbers and special characters, say name_1,

\expandafter\def\csname name_1\endcsname{value}%


must be written to the data file.

\csname name_1\endcsname then expands to its value wherever you place it in your main document.

Don't forget to terminate data lines with %. It avoids spurious spaces in the final LaTeX output.

-
Nice idea! That solves the problem very elegantly. – eudoxos Oct 27 '11 at 8:38