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.
33 lines
1.1 KiB
33 lines
1.1 KiB
import datetime
|
|
|
|
def kPlusProches(lst[0][1], lst):
|
|
|
|
|
|
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")
|
|
num_day = day.strftime('%j')
|
|
return int(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
|
|
|
|
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
|
|
|
|
lst = lecture("jeuTests.csv")
|
|
dist = distance(lst[0][1],lst[1][1])
|
|
|