From f87d2108bd743ed1efe6104c4e5d75150750df1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CLOCHARD=20L=C3=A9andre?= Date: Thu, 12 May 2022 09:43:47 +0200 Subject: [PATCH] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit creation fonction numero jour --- lecture_csv.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lecture_csv.py b/lecture_csv.py index cf52f1a..dd1bf85 100644 --- a/lecture_csv.py +++ b/lecture_csv.py @@ -1,21 +1,26 @@ +import datetime + +def numeroJour(date): + """renvoie un entier correspondant au numéro du jour correspondant (entre 1 et 365)""" + day = datetime.datetime.strptime(date, "%Y-%m-%d") + num_day = day.strftime('%j') + return num_day + def lecture(name): """lit le fichier csv dont le nom est passé en paramètre, en renvoie trois tableau contenant respectivement la longueur et la largeur des pétales, et l'espèce de l'iris.""" - lst_date = [] - lst_pic = [] - lst_temp_moy = [] - lst_temp_ref = [] + lst_return = [] with open(name) as fic: fic.readline() for ligne in fic: date, pic, temp_moy, temp_ref = ligne.split(';') - lst_date.append(date) - lst_pic.append(float(pic)) - lst_temp_moy.append(float(temp_moy)) - lst_temp_ref.append(float(temp_ref)) - - - return lst_date, lst_pic, lst_temp_moy, lst_temp_ref + tuple_date = (numeroJour(date) ,float(temp_moy), float(temp_ref)) + lst_return.append([float(pic), tuple_date]) + + return lst_return print(lecture("jeuTests.csv")) - \ No newline at end of file + + + + \ No newline at end of file