2025-03-22 00:49:46 +01:00

25 lines
663 B
Python

import csv
tab_donnees = []
nb_total = []
d={}
'''
def max(tab):
max=tab[0]
for i in range (len(tab)):
if max < tab[i]:
max = tab[i]
return max
'''
with open("nat2022.csv", newline ='', encoding="utf-8") as csvfile:
donnees = csv.DictReader(csvfile, delimiter= ";")
for ligne in donnees:
tab_donnees.append(dict(ligne))
for ligne in tab_donnees:
ligne["nombre"] = int(ligne["nombre"])
for prenom in tab_donnees:
if prenom['sexe'] == '1' and prenom['annais'] == '2008':
d[prenom["preusuel"]] = d.get(prenom["preusuel"], prenom["nombre"])
maxi = max(d, key=d.get)
print(maxi)