I do not know how to import a function from another file using pycode.
I have a file named csv_code.py with the following code,
import csv
def create_csv():
header = ['name', 'degree']
data = ['Mark', 6]
with open('degrees.csv', 'w', encoding='UTF8', newline='') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerow(data)
and in the same directory, I have a .tex file containing this code
\documentclass{article}
\usepackage{csvsimple}
\usepackage{pythontex}
\begin{document}
\begin{pycode}
from csv_code import *
create_csv()
\end{pycode}
\csvautotabular{countries.csv}
\end{document}
It works good, but once it has been compiled if the code in csv_code is changed (let's say that instead of Mark now we use the name John) when compiled again the document doesn't suffer any changes.
I assume LaTeX is just lazy and as it has run that code already it doesn't run it again. Is there a way of forcing LaTeX to run that code every time?
I have read here a solution using --shell-escape. But I don't know how to set this up in VSCode and I would like to find a way that doesn't involve playing with the settings to make it easier if I share my code.
pytex.add_dependencies()function of PythonTeX? Like here https://github.com/gpoore/pythontex/issues/27#issuecomment-28412480 – May 04 '22 at 15:17