## How to insert data extracted from a csv file?

I would like to insert data extracted from an externally loaded table (csv, ods, xls, etc). For example, exam number 1 uses the first line of the file, exam 2 uses the second line, and so on. Is it possible to do this with automultiplechoice?

### Replies (4)

#### RE: How to insert data extracted from a csv file? - Added by Alexis Bienvenüeabout 5 years ago

Maybe have a look at documentation, section 7.1: nominative sheets?

#### RE: How to insert data extracted from a csv file? - Added by Marcos Viniciusabout 5 years ago

Yes, I have already done that. My question is, for example:
I use a "student.csv" file like that:

name,forename,idBoulix,Jojo,001Golin,André,002Moniuszko,Stanisław,003

and a separate data file (data.csv) like that:
var1,var2,var3,var41,2,3,45,6,7,89,10,11,12

I want associate the first line of the data file with the first student and so on without putting the data variables as columns of student.csv.

#### RE: How to insert data extracted from a csv file? - Added by Frédéric Bréalabout 5 years ago

I tried with the datatool package.

\DTLgetvalue{\command}{database}{row number}{column number}

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{datatool,csvsimple} %

\usepackage[bloc,outsidebox]{automultiplechoice}

%pour obtenir le numéro du sujet
\makeatletter
\def\Nsujet{\the\AMCid@etud}
\makeatother
\renewcommand{\AMCsubjectPageTag}{\Nsujet}

%%%§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
\newcommand{\sujet}{
\onecopy{1}{ %
%%%%%%%%%%%%%%%%%En tête de la copie %%%%%%%%%%%%%%%%

\noindent{}\champnom{\fbox{
\begin{minipage}{0.97\linewidth}
{\Large\bf\nom{}~\prenom{}}  \hfill\null
\vspace*{1mm}
\end{minipage}
}}\medskip%

%aller à la ligne n° i qui correspond au numéro du sujet
\begin{question}{A}
\DTLgetvalue{\Var1}{data}{\Nsujet}{1}
What is the next number following \Var1 ?
\AMCOpen{lines=1}{\mauvaise[0.25]{0,25}\bareme{0.25}\mauvaise[0.50]{0,5}\bareme{0.5}\mauvaise[0.75]{0,75}\bareme{0.75}\bonne[1]{1}\bareme{1}}
\end{question}

\DTLgetvalue{\Var1}{data}{\Nsujet}{1}
\begin{question}{\Var1}
What is the next number following \Var1 ?
\AMCOpen{lines=1}{\mauvaise[0.25]{0,25}\bareme{0.25}\mauvaise[0.50]{0,5}\bareme{0.5}\mauvaise[0.75]{0,75}\bareme{0.75}\bonne[1]{1}\bareme{1}}
\end{question}

\AMCassociation{\identifiant}
}
}
%%%%§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

\begin{document}