Manage csv file now
This commit is contained in:
parent
dee5ba4812
commit
7eb2151d87
19
DS_gene.py
19
DS_gene.py
@ -4,6 +4,7 @@
|
||||
import os
|
||||
import sys
|
||||
import optparse
|
||||
import csv
|
||||
from path import path
|
||||
|
||||
from texenv import texenv
|
||||
@ -24,17 +25,23 @@ def main(options):
|
||||
# Template should be named tpl_... tpl will replace by the number/name of the version
|
||||
output = path(template_file.dirname()) / path(template_file.name[3:])
|
||||
|
||||
if not options.csv_file:
|
||||
list_infos = [{num: i+1} for i in range(options.num_subj)]
|
||||
else:
|
||||
with open(options.csv_file, 'r', encoding = 'ISO-8859-1') as f:
|
||||
list_infos = list(csv.DictReader(f, delimiter=";"))
|
||||
for (i,a) in enumerate(list_infos):
|
||||
a['num'] = i+1
|
||||
|
||||
if output.dirname() != "":
|
||||
output.dirname().cd()
|
||||
|
||||
output = output.name
|
||||
|
||||
|
||||
for subj in range(options.num_subj):
|
||||
subj = subj+1
|
||||
dest = path(str(subj) + output)
|
||||
for infos in list_infos:
|
||||
dest = path(str(infos['num']) + output)
|
||||
with open( dest, 'w') as f:
|
||||
f.write(template.render( RdExpression = RdExpression , infos = {"subj" : subj}))
|
||||
f.write(template.render( RdExpression = RdExpression , infos = infos))
|
||||
|
||||
if not options.no_compil:
|
||||
os.system("pdflatex " + dest)
|
||||
@ -50,10 +57,12 @@ if __name__ == '__main__':
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-t","--template",action="store",type="string",dest="template", help="File with the template. The name should have the following form tpl_... .")
|
||||
parser.add_option("-o","--output",action="store",type="string",dest="output",help="Base name for output )")
|
||||
parser.add_option("-c","--csv", action="store", type="string", dest="csv_file", help="Filename of the csv file where informations are stored")
|
||||
parser.add_option("-N","--number_subjects", action="store",type="int", dest="num_subj", default = 1, help="The number of subjects to make")
|
||||
parser.add_option("-d","--dirty", action="store_true", dest="dirty", help="Do not clean after compilation")
|
||||
parser.add_option("-n","--no-compile", action="store_true", dest="no_compil", help="Do not compile source code")
|
||||
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if not options.template:
|
||||
|
25
example/csv_example.csv
Normal file
25
example/csv_example.csv
Normal file
@ -0,0 +1,25 @@
|
||||
Classe;Nom;Prenom;identifiant;mdp
|
||||
6A;ASSAOUA;Najwa;nassaoua;zajulu
|
||||
6A;AUDINOT;Lea;laudinot;padito
|
||||
6A;CARVALHO GOUVEIA;Ana Filipa;acarvalhogo;fekovo
|
||||
6A;CASALTA;Marine;mcasalta9;wufuzu
|
||||
6A;CASU;Stella-Maria;scasu;jixuyu
|
||||
6A;DEBLY;Laura;ldebly;cazema
|
||||
6A;ERNANDES;Carla;cernandes;kahisi
|
||||
6A;ETIENNE;Melvin;metienne2;jimico
|
||||
6A;GAILLARD;Dorian;dgaillard;lazofi
|
||||
6A;GUIDONI;Dominique;dguidoni4;zojihi
|
||||
6A;HAMMAMI;Oumaïma;ohammami;sugaga
|
||||
6A;KHEZAMI;Mohamed;mkhezami2;pomeve
|
||||
6A;KUREK-PINELLI;Ristituda;rkurekpinel;xawunu
|
||||
6A;LARROQUE;Nino;nlarroque;jivanu
|
||||
6A;MABIRE;Luca;lmabire;menazi
|
||||
6A;MATIC;Veljko;vmatic;pijofa
|
||||
6A;MOUAOU;Saâd;smouaou;ruroyo
|
||||
6A;PERRIN;Nicolas;nperrin4;xenige
|
||||
6A;PIRES NASCIMENTO;Guillaume;gpiresnasci;yixone
|
||||
6A;QUARDELLE;Olivier;oquardelle;yekezo
|
||||
6A;RANCUREL;Fabio;francurel;dowabo
|
||||
6A;SPINOSI;ALEXANDRE;aspinosi;pebidi
|
||||
6A;VERBEKE;Hugo;hverbeke;xucibo
|
||||
6A;WATIN;Anthony;awatin;sucavo
|
|
@ -9,7 +9,7 @@
|
||||
% DS DSCorr DM DMCorr Corr
|
||||
\typedoc{DS}
|
||||
\duree{1 heure}
|
||||
\sujet{\Var{infos.subj}}
|
||||
\sujet{\Var{infos.Nom}}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
Loading…
Reference in New Issue
Block a user