diff --git a/example/tribe1.csv b/example/tribe1.csv index 27fec17..bf11d99 100644 --- a/example/tribe1.csv +++ b/example/tribe1.csv @@ -1,4 +1,4 @@ -nom,email +Nom,email Star Tice,stice0@jalbum.net Umberto Dingate,udingate1@tumblr.com Starlin Crangle,scrangle2@wufoo.com diff --git a/example/tribe2.csv b/example/tribe2.csv index f56d38a..21d5ff7 100644 --- a/example/tribe2.csv +++ b/example/tribe2.csv @@ -1,4 +1,4 @@ -nom,email +Nom,email Elle McKintosh,emckintosh0@1und1.de Ty Megany,tmegany1@reuters.com Pippa Borrows,pborrows2@a8.net diff --git a/recopytex/scripts/recopytex.py b/recopytex/scripts/recopytex.py index 01afe95..179e1c8 100644 --- a/recopytex/scripts/recopytex.py +++ b/recopytex/scripts/recopytex.py @@ -5,10 +5,12 @@ import click from pathlib import Path import sys import papermill as pm +import pandas as pd from datetime import datetime from .getconfig import config from .prompts import prompt_exam, prompt_exercise +from ..config import NO_ST_COLUMNS @click.group() @@ -42,7 +44,8 @@ def exam_dict2element(exam): "term": exam["term"], "assessment": exam["name"], "date": exam["date"].strftime("%d/%m/%Y"), - "exercice": ex["name"], + "exercise": ex["name"], + "question": q["id"], **q, } ) @@ -56,7 +59,23 @@ def new_exam(): exam["exercices"] = [] for ex in range(int(exam["ExQty"])): exam["exercices"].append(prompt_exercise(ex + 1)) - print(exam_dict2element(exam)) + + elements = exam_dict2element(exam) + + base_df = pd.DataFrame.from_dict(elements)[NO_ST_COLUMNS.keys()] + base_df.rename(columns=NO_ST_COLUMNS, inplace=True) + + students = pd.read_csv(exam["tribe"]["students"])["Nom"] + for student in students: + base_df[student] = "" + + dest = ( + Path(config["source"]) + / exam["tribe"]["name"] + / f"{exam['date'].strftime('%y%m%d')}_{exam['name']}.csv" + ) + base_df.to_csv(dest, index=False) + print(f"Le fichier note a été enregistré à {dest}") @cli.command()