You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

import datetime
3 years ago
def estBissextile(date):
date = date.split("-")
if int(date[0])%4 == 0:
return True
else:
return False
def numeroJour(date):
"""renvoie un entier correspondant au numéro du jour correspondant (entre 1 et 365)"""
try:
day = datetime.datetime.strptime(date, "%Y-%m-%d")
3 years ago
num_day = int(day.strftime('%j'))
if estBissextile(date) and num_day == 366:
num_day = 365
return num_day
except(ValueError):
return None
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_return = []
with open(name) as fic:
fic.readline()
for ligne in fic:
date, pic, temp_moy, temp_ref = ligne.split(';')
tuple_date = (numeroJour(date) ,float(temp_moy), float(temp_ref))
lst_return.append([float(pic), tuple_date])
return lst_return
3 years ago
def distance(tup_1, tup_2):
mn = (tup_1[0]-tup_2[0])**2+(tup_1[1]-tup_2[1])**2+(tup_1[2]-tup_2[2])**2
return mn
3 years ago
lst = lecture("jeuTests.csv")
dist = distance(lst[0][1],lst[1][1])