Text Formatting ⇒ Import result from Python into regular sentence
Import result from Python into regular sentence
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.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Import result from Python into regular sentence
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}