Hi
Im writing a book with Latex and looking for a way to import values calculated outside into a standard sentence.
Pythonscript:
Eriks birthday: 770101
Erik_age =today - 770101
Output from formatted Latexfile:
Erik is 45 years old
I want the age to be formatted as normal text. For the reader it shouldnt be visible that there was a calculation behind the age data.
There are a lot of examples where input is formatted as a table. But nothing on inserting data into normal text.
Text Formatting ⇒ Import result from Python into regular sentence
NEW: TikZ book now 40% off at Amazon.com for a short time.

Import result from Python into regular sentence
You could calculate the age of several people with Python and write the result in a text file. With the help of the
datatool package, you could then select the value you are looking for and print it at the desired place.

Code: Select all
\begin{filecontents}{data.csv}
name,age
Erik,45
John,28
Mike,32
\end{filecontents}
\documentclass{article}
\usepackage{datatool}
\DTLloaddb{people}{data.csv}
\begin{document}
Erik is \DTLfetch{people}{name}{Erik}{age} years old.
\end{document}
Import result from Python into regular sentence
Great! Exactly what Ive been looking for, Thanks!