diff --git a/lecture_csv.py b/lecture_csv.py index 867caf2..cf52f1a 100644 --- a/lecture_csv.py +++ b/lecture_csv.py @@ -1,10 +1,21 @@ -import csv - -def lecture(fichier_csv): - "renvoie un tabeau" - with open(fichier_csv, newline='') as csvfile: - spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') - for row in spamreader: - print(', '.join(row)) - -lecture("jeuTests.csv") \ No newline at end of file +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 = [] + 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 + +print(lecture("jeuTests.csv")) + \ No newline at end of file