3

I just started using csvsimple which looks like a great package. I wonder if it was possible to do the following

Let's say that I have a .csv file that I copy into the .tex file as follows:

\documentclass{article}
\usepackage{csvsimple}

\begin{filecontents*}{grade.csv}
    name,givenname,matriculation,gender,grade
    Maier,Hans,12345,m,1.0
    Huber,Anna,23456,f,2.3
    Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}

\begin{document}
    \begin{tabular}{l|c}%
        \bfseries Person & \bfseries Matr.~No.% specify table head
        \csvreader[head to column names]{grade.csv}{}% use head of csv as column names
        {\\\hline\givenname\ \name & \matriculation}% specify your columns here
    \end{tabular}
\end{document}

\end{document}

which generates a pdf with a table without Problem

However, let's say that I want to change the content of the csv file in the .tex file, e.g. I want to rename the variable givenname to givennamex

\documentclass{article}
\usepackage{csvsimple}

\begin{filecontents*}{grade.csv}
    name,givennamex,matriculation,gender,grade
    Maier,Hans,12345,m,1.0
    Huber,Anna,23456,f,2.3
    Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}

\begin{document}
    \begin{tabular}{l|c}%
        \bfseries Person & \bfseries Matr.~No.% specify table head
        \csvreader[head to column names]{grade.csv}{}% use head of csv as column names
        {\\\hline\givennamex\ \name & \matriculation}% specify your columns here
    \end{tabular}
\end{document}

\end{document}

This actually doesn't work. It works however if I manually delete the generated grade.csv file before compiling the file again. The Thing, I believe it that Latex generates a .csv file from the first compile, but it doesn't update the .csv file on the second compile

Is there a way that the generated .csv file gets updated when I do change on the content of the .csv file?

many thanks in advance

1 Answer 1

3

Add \usepackage{filecontents} to the preamble (obviously before of the filecontents* environment).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .