Skip to content
Extraits de code Groupes Projets
Valider 50e8e88e rédigé par Adrien Payen's avatar Adrien Payen
Parcourir les fichiers

modifying in english

parent a5ff3af0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -4,331 +4,340 @@ import os ...@@ -4,331 +4,340 @@ import os
import statistics import statistics
import re import re
file_path = '/content/Data_Base.xlsx' file_path = '/content/Data_Base.xlsx'
data = pd.read_excel(file_path) data = pd.read_excel(file_path)
page_excel = 'exporter_les_noms.xlsx' excel_file_path = 'export_names.xlsx'
menu = [] menu = []
Name_pattern = re.compile(r'^[A-Za-zéèêëàâäôöûüçÉÈÊËÀÂÄÔÖÛÜÇ][A-Za-zéèêëàâäôöûüçÉÈÊËÀÂÄÔÖÛÜÇ\'\-]*$') name_pattern = re.compile(r'^[A-Za-zéèêëàâäôöûüçÉÈÊËÀÂÄÔÖÛÜÇ][A-Za-zéèêëàâäôöûüçÉÈÊËÀÂÄÔÖÛÜÇ\'\-]*$')
Date_pattern = re.compile(r'^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\d{4}$') date_pattern = re.compile(r'^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\d{4}$')
Place_of_birth_pattern = re.compile(r'^[A-Za-zÀ-ÖØ-öø-ÿ\s]+$') place_of_birth_pattern = re.compile(r'^[A-Za-zÀ-ÖØ-öø-ÿ\s]+$')
Address_pattern = re.compile(r'^[A-Za-z\s]+ \d+, [A-Za-z\s]+$') address_pattern = re.compile(r'^[A-Za-z\s]+ \d+, [A-Za-z\s]+$')
Telephone_pattern = re.compile(r'^\d{3}/\d{2}\.\d{2}\.\d{2}$') telephone_pattern = re.compile(r'^\d{3}/\d{2}\.\d{2}\.\d{2}$')
Email_pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@student\.uclouvain\.be$') email_pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@student\.uclouvain\.be$')
Genre_pattern = re.compile(r'^[MFO]$') gender_pattern = re.compile(r'^[MFO]$')
Academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$') academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$')
Campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE) campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE)
# REGISTER # REGISTER
def enregistrer_eleve(data) : def register_student(data):
# mise en place des patterns a respecter pour rentrer les informations # Setting up the patterns to follow for entering information
while True: while True:
Name = input("Quel est son nom ? ") # Demander le nom à l'utilisateur Name = input("What is the student's name? ") # Ask the user for the name
if Name_pattern.match(Name): # Vérifier si le nom correspond au format spécifié if name_pattern.match(Name): # Check if the name matches the specified format
print("Le nom est valide.") print("The name is valid.")
break # Sortir de la boucle si le nom est valide break # Exit the loop if the name is valid
else:
print("Le nom n'est pas valide. Assurez-vous de suivre le format spécifié.")
while True: # Demander le prénom à l'utilisateur
Surname = input("Quel est son prénom ? ") # Vérifier si le prénom correspond au format spécifié
if Name_pattern.match(Surname):
print("Le prénom est valide.")
break # Sortir de la boucle si le prénom est valide
else:
print("Le prénom n'est pas valide. Assurez-vous de suivre le format spécifié.")
while True:
Date_of_birth = input("Veuillez entrer une date au format jj/mm/yyyy : ")
if Date_pattern.match(Date_of_birth):
print("La date est valide.")
break # Sortir de la boucle si la date est valide
else:
print("La date n'est pas valide. Assurez-vous de suivre le format jj/mm/yyyy.")
while True:
Place_of_birth = input("Quelle est la ville de naissance ? ")
if Place_of_birth_pattern.match(Place_of_birth):
print("La ville de naissance est valide.")
break # Sortir de la boucle si la ville de naissance est valide
else:
print("La ville de naissance n'est pas valide. Assurez-vous d'utiliser uniquement des lettres et des espaces.")
while True:
Address = input("Veuillez entrer une adresse au format 'rue numéro, ville' : ")
if Address_pattern.match(Address):
print("L'adresse est valide.")
break # Sortir de la boucle si l'adresse est valide
else: else:
print("L'adresse n'est pas valide. Assurez-vous de suivre le format 'rue numéro, ville'.") print("The name is not valid. Make sure to follow the specified format.")
while True:
Telephone = input("Quel est son numéro de téléphone ? (à mettre au format 000/00.00.00) ") while True:
if Telephone_pattern.match(Telephone): Surname = input("What is the student's surname? ") # Ask the user for the surname
print("Le numéro de téléphone est valide.") if name_pattern.match(Surname):
break # Sortir de la boucle si le numéro de téléphone est valide print("The surname is valid.")
break # Exit the loop if the surname is valid
else: else:
print("Le numéro de téléphone n'est pas valide. Assurez-vous de suivre le format demandé.") print("The surname is not valid. Make sure to follow the specified format.")
while True:
Email = input("Entrez l'email de l'université (@student.uclouvain.be) : ") while True:
if Email_pattern.match(Email): Date_of_birth = input("Please enter a date in the format dd/mm/yyyy: ")
print("L'email est valide.") if date_pattern.match(Date_of_birth):
break # Sortir de la boucle si l'email est valide print("The date is valid.")
break # Exit the loop if the date is valid
else: else:
print("L'email n'est pas valide. Assurez-vous de suivre le format demandé.") print("The date is not valid. Make sure to follow the format dd/mm/yyyy.")
while True:
Genre = input("Quel est votre sexe ? (Pour Homme entrez M, pour Femme entrez F, et pour un autre type entrez O) : ") while True:
if Genre_pattern.match(Genre): Place_of_birth = input("What is the city of birth? ")
print("Le genre est valide.") if place_of_birth_pattern.match(Place_of_birth):
break # Sortir de la boucle si le genre est valide print("The city of birth is valid.")
else: break # Exit the loop if the city of birth is valid
print("Le genre n'est pas valide. Assurez-vous de suivre le format demandé.")
while True:
Academic_year = input("Quelle est votre année académique ? (BAC1/BAC2/BAC3/MA1/MA2) : ")
if Academic_year_pattern.match(Academic_year):
print("L'année académique est valide.")
break # Sortir de la boucle si l'année académique est valide
else: else:
print("L'année académique n'est pas valide. Assurez-vous de suivre le format demandé.") print("The city of birth is not valid. Make sure to use only letters and spaces.")
Courses_and_grade = {}
if Academic_year == 'MA2': while True:
for cours in coursBAC1 + coursBAC2 + coursBAC3 + coursMA1 + coursMA2 : Address = input("Please enter an address in the format 'street number, city': ")
note = input(f"Quelle est la note pour {cours} ? ") if address_pattern.match(Address):
while not note.isdigit() or int(note) not in range(0, 21): print("The address is valid.")
print("La note doit être un nombre entier entre 0 et 20.") break # Exit the loop if the address is valid
note = input(f"Quelle est la note pour {cours} ? ")
Courses_and_grade[cours] = int(note)
elif Academic_year == 'MA1':
for cours in coursBAC1 + coursBAC2 + coursBAC3 + coursMA1 :
note = input(f"Quelle est la note pour {cours} ? ")
while not note.isdigit() or int(note) not in range(0, 21):
print("La note doit être un nombre entier entre 0 et 20.")
note = input(f"Quelle est la note pour {cours} ? ")
Courses_and_grade[cours] = int(note)
elif Academic_year == 'BAC3':
for cours in coursBAC1 + coursBAC2 + coursBAC3 :
note = input(f"Quelle est la note pour {cours} ? ")
while not note.isdigit() or int(note) not in range(0, 21):
print("La note doit être un nombre entier entre 0 et 20.")
note = input(f"Quelle est la note pour {cours} ? ")
Courses_and_grade[cours] = int(note)
elif Academic_year == 'BAC2':
for cours in coursBAC1 + coursBAC2 :
note = input(f"Quelle est la note pour {cours} ? ")
while not note.isdigit() or int(note) not in range(0, 21):
print("La note doit être un nombre entier entre 0 et 20.")
note = input(f"Quelle est la note pour {cours} ? ")
Courses_and_grade[cours] = int(note)
elif Academic_year == 'BAC1':
for cours in coursBAC1 :
note = input(f"Quelle est la note pour {cours} ? ")
while not note.isdigit() or int(note) not in range(0, 21):
print("La note doit être un nombre entier entre 0 et 20.")
note = input(f"Quelle est la note pour {cours} ? ")
Courses_and_grade[cours] = int(note)
while True:
Campus = input("Entrez 'Louvain-la-Neuve' ou 'Mons' en fonction du campus : ")
if Campus_pattern.match(Campus):
print("Le choix du campus est valide.")
break # Sortir de la boucle si le choix du campus est valide
else: else:
print("Le choix du campus n'est pas valide. Assurez-vous de suivre le format demandé.") print("The address is not valid. Make sure to follow the format 'street number, city'.")
enregistrer(data,Name, Surname, Date_of_birth, Place_of_birth, Address, Telephone, Email, Genre, Academic_year, Courses_and_grade, Campus) while True:
Telephone = input("What is the telephone number? (in the format 000/00.00.00) ")
if telephone_pattern.match(Telephone):
print("The telephone number is valid.")
break # Exit the loop if the telephone number is valid
else:
print("The telephone number is not valid. Make sure to follow the requested format.")
while True:
Email = input("Enter the university email (@student.uclouvain.be): ")
if email_pattern.match(Email):
print("The email is valid.")
break # Exit the loop if the email is valid
else:
print("The email is not valid. Make sure to follow the requested format.")
def enregistrer(data, Name, Surname, Date_of_Birth, Place_of_Birth, Address, Telephone, Email, Genre, Academic_year, Courses_and_grade, Campus): while True:
Gender = input("What is your gender? (For Male enter M, for Female enter F, and for another type enter O): ")
if gender_pattern.match(Gender):
print("The gender is valid.")
break # Exit the loop if the gender is valid
else:
print("The gender is not valid. Make sure to follow the requested format.")
Matricule = generer_matricule(Name, Surname, Date_of_Birth) while True:
Academic_year = input("What is your academic year? (BAC1/BAC2/BAC3/MA1/MA2): ")
if academic_year_pattern.match(Academic_year):
print("The academic year is valid.")
break # Exit the loop if the academic year is valid
else:
print("The academic year is not valid. Make sure to follow the requested format.")
Courses_and_grade = {}
if Academic_year == 'MA2':
for course in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 + all_course_MA1 + all_course_MA2:
grade = input(f"What is the grade for {course}? ")
while not grade.isdigit() or int(grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
grade = input(f"What is the grade for {course}? ")
Courses_and_grade[course] = int(grade)
elif Academic_year == 'MA1':
for course in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 + all_course_MA1:
grade = input(f"What is the grade for {course}? ")
while not grade.isdigit() or int(grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
grade = input(f"What is the grade for {course}? ")
Courses_and_grade[course] = int(grade)
elif Academic_year == 'BAC3':
for course in all_course_BAC1 + all_course_BAC2 + all_course_BAC3:
grade = input(f"What is the grade for {course}? ")
while not grade.isdigit() or int(grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
grade = input(f"What is the grade for {course}? ")
Courses_and_grade[course] = int(grade)
elif Academic_year == 'BAC2':
for course in all_course_BAC1 + all_course_BAC2:
grade = input(f"What is the grade for {course}? ")
while not grade.isdigit() or int(grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
grade = input(f"What is the grade for {course}? ")
Courses_and_grade[course] = int(grade)
elif Academic_year == 'BAC1':
for course in all_course_BAC1:
grade = input(f"What is the grade for {course}? ")
while not grade.isdigit() or int(grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
grade = input(f"What is the grade for {course}? ")
Courses_and_grade[course] = int(grade)
etudiant = { while True:
"Name": Name, Campus = input("Enter 'Louvain-la-Neuve' or 'Mons' depending on the campus: ")
"Surname": Surname, if campus_pattern.match(Campus):
"Date of Birth": Date_of_Birth, print("The campus choice is valid.")
"Place of Birth": Place_of_Birth, break # Exit the loop if the campus choice is valid
"Address": Address, else:
"Telephone": Telephone, print("The campus choice is not valid. Make sure to follow the requested format.")
"Email": Email,
"Genre": Genre, register(data, Name, Surname, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus)
"Academic Year": Academic_year,
"Campus": Campus,
"Matricule": Matricule def register(data, name, surname, date_of_birth, place_of_birth, address, telephone, email, gender, academic_year, courses_and_grade, campus):
matricule = generate_matricule(name, surname, date_of_birth)
student = {
"Name": name,
"Surname": surname,
"Date of Birth": date_of_birth,
"Place of Birth": place_of_birth,
"Address": address,
"Telephone": telephone,
"Email": email,
"Gender": gender,
"Academic Year": academic_year,
"Campus": campus,
"Matricule": matricule
} }
for cours, note in Courses_and_grade.items(): for course, grade in courses_and_grade.items():
etudiant[cours] = note student[course] = grade
data = pd.concat([data, etudiant], ignore_index=True) data = pd.concat([data, student], ignore_index=True)
data.to_excel(file_path, index=False) data.to_excel(file_path, index=False)
print('La personne a été enregistrée.\n') print('The person has been registered.\n')
return return
def generer_matricule(Name, Surname, Date_of_birth) : def generate_matricule(name, surname, date_of_birth):
consonnes_nom = ''.join([c for c in Name if c.lower() not in 'aeiouy'])[:3] consonants_name = ''.join([c for c in name if c.lower() not in 'aeiouy'])[:3]
consonnes_prenom = ''.join([c for c in Surname if c.lower() not in 'aeiouy'])[:2] consonants_surname = ''.join([c for c in surname if c.lower() not in 'aeiouy'])[:2]
derniere_consonne_nom = ''.join([c for c in Surname if c.lower() not in 'aeiouy']).lower()[-1] # ne sait pas si c'est la consonne du prénom ou du nom last_consonant_surname = ''.join([c for c in surname if c.lower() not in 'aeiouy']).lower()[-1] # not sure if it's the consonant of the first name or the last name
annee_naissance_str = str(Date_of_birth)[-2:] birth_year_last_two_digits = str(date_of_birth)[-2:]
entier_aleatoire = random.randint(0, 10) random_integer = random.randint(0, 10)
matricule_e = f"{consonnes_nom}{consonnes_prenom}{derniere_consonne_nom}{annee_naissance_str}{entier_aleatoire}" matricule_e = f"{consonants_name}{consonants_surname}{last_consonant_surname}{birth_year_last_two_digits}{random_integer}"
matricule_e = matricule_e.lower() matricule_e = matricule_e.lower()
return matricule_e return matricule_e
# MODIFY
def modifier(data) : # il faudrait pouvoir modifier plusieurs champs sans soucis et ne pas remttre le matricule une fois rentrer
# matricule ne peut être modifié, il est unique donc je me base sur cela.
while True :
data_to_modify = input("Entrez le matricule de l'étudiant que vous souhaitez modifier (ou 'q pour quitter) : ")
if data_to_modify.lower() == 'q' :
print("Opération annulée.")
break
student_index = data[data['Matricule'] == data_to_modify.lower()].index.tolist()
if not student_index : def modify(data):
print("Aucun étudiant n'a été trouvé avec le matricule que vous avez spécifié.") while True:
return matricule_to_modify = input("Enter the matricule of the student you want to modify (or 'q' to quit): ")
if matricule_to_modify.lower() == 'q':
student_index = student_index[0] print("Operation canceled.")
print(f"\nModification de l'étudiant avec le matricule {data_to_modify} :\n") break
print("1. Name")
print("2. Surname") student_index = data[data['Matricule'] == matricule_to_modify.lower()].index.tolist()
print("3. Date of Birth")
print("4. Place of Birth") if not student_index:
print("5. Address") print("No student found with the specified matricule.")
print("6. Telephone") return
print("7. Email")
print("8. Sex (M | F | O)") student_index = student_index[0]
print("9. Academic Year") print(f"\nModifying the student with matricule {matricule_to_modify}:\n")
print("10. Curriculum") print("1. Name")
print("11. Courses already passed and their grade") print("2. Surname")
print("12. Campus") print("3. Date of Birth")
print("4. Place of Birth")
field_to_modify = int(input("Entrez le numéro du champ que vous souhaitez modifier : ")) print("5. Address")
print("6. Telephone")
field_name_to_modify = field_mapping.get(field_to_modify, None) print("7. Email")
print(f"Vous modifiez le champ : {field_name_to_modify}") print("8. Sex (M | F | O)")
print("9. Academic Year")
if field_to_modify == 1: # Si le champ à modifier est le nom (Name) print("10. Curriculum")
while True: print("11. Courses already passed and their grade")
Name = input("Quel est le nom que vous voulez modifier ? ") print("12. Campus")
if Name_pattern.match(Name):
print("Le nom est valide.") field_to_modify = int(input("Enter the number of the field you want to modify: "))
# Ajoutez ici le code pour mettre à jour le champ dans vos données
break # Sortir de la boucle si le nom est valide field_name_to_modify = field_mapping.get(field_to_modify, None)
else: print(f"You are modifying the field: {field_name_to_modify}")
print("Le nom n'est pas valide. Assurez-vous de suivre le format spécifié.")
elif field_to_modify == 2: if field_to_modify == 1: # If the field to modify is the name (Name)
while True: # Demander le prénom à l'utilisateur while True:
Surname = input("Quel est son prénom ? ") # Vérifier si le prénom correspond au format spécifié name = input("What is the name you want to modify? ")
if Name_pattern.match(Surname): if name_pattern.match(name):
print("Le prénom est valide.") print("The name is valid.")
break # Sortir de la boucle si le prénom est valide data.at[student_index, 'Name'] = name
else: break # Exit the loop if the name is valid
print("Le prénom n'est pas valide. Assurez-vous de suivre le format spécifié.") else:
elif field_to_modify == 3 : print("The name is not valid. Make sure to follow the specified format.")
while True: elif field_to_modify == 2:
Date_of_birth = input("Veuillez entrer une date au format jj/mm/yyyy : ") while True: # Ask the user for the surname
if Date_pattern.match(Date_of_birth): surname = input("What is the surname? ")
print("La date est valide.") if name_pattern.match(surname):
break # Sortir de la boucle si la date est valide print("The surname is valid.")
else: data.at[student_index, 'Surname'] = surname
print("La date n'est pas valide. Assurez-vous de suivre le format jj/mm/yyyy.") break # Exit the loop if the surname is valid
elif field_to_modify == 4 : else:
while True: print("The surname is not valid. Make sure to follow the specified format.")
Place_of_birth = input("Quelle est la ville de naissance ? ") elif field_to_modify == 3:
if Place_of_birth_pattern.match(Place_of_birth): while True:
print("La ville de naissance est valide.") date_of_birth = input("Please enter a date in the format dd/mm/yyyy: ")
break # Sortir de la boucle si la ville de naissance est valide if date_pattern.match(date_of_birth):
else: print("The date is valid.")
print("La ville de naissance n'est pas valide. Assurez-vous d'utiliser uniquement des lettres et des espaces.") data.at[student_index, 'Date of Birth'] = date_of_birth
elif field_to_modify == 5 : break # Exit the loop if the date is valid
while True: else:
Address = input("Veuillez entrer une adresse au format 'rue numéro, ville' : ") print("The date is not valid. Make sure to follow the format dd/mm/yyyy.")
if Address_pattern.match(Address): elif field_to_modify == 4:
print("L'adresse est valide.") while True:
break # Sortir de la boucle si l'adresse est valide place_of_birth = input("What is the city of birth? ")
else: if place_of_birth_pattern.match(place_of_birth):
print("L'adresse n'est pas valide. Assurez-vous de suivre le format 'rue numéro, ville'.") print("The city of birth is valid.")
elif field_to_modify == 6 : data.at[student_index, 'Place of Birth'] = place_of_birth
while True: break # Exit the loop if the city of birth is valid
Telephone = input("Quel est son numéro de téléphone ? (à mettre au format 000/00.00.00) ") else:
if Telephone_pattern.match(Telephone): print("The city of birth is not valid. Make sure to use only letters and spaces.")
print("Le numéro de téléphone est valide.") elif field_to_modify == 5:
break # Sortir de la boucle si le numéro de téléphone est valide while True:
else: address = input("Please enter an address in the format 'street number, city': ")
print("Le numéro de téléphone n'est pas valide. Assurez-vous de suivre le format demandé.") if address_pattern.match(address):
elif field_to_modify == 7 : print("The address is valid.")
while True: data.at[student_index, 'Address'] = address
Email = input("Entrez l'email de l'université (@student.uclouvain.be) : ") break # Exit the loop if the address is valid
if Email_pattern.match(Email): else:
print("L'email est valide.") print("The address is not valid. Make sure to follow the format 'street number, city'.")
break # Sortir de la boucle si l'email est valide elif field_to_modify == 6:
else: while True:
print("L'email n'est pas valide. Assurez-vous de suivre le format demandé.") telephone = input("What is the telephone number? (in the format 000/00.00.00) ")
elif field_to_modify == 8 : if telephone_pattern.match(telephone):
while True: print("The telephone number is valid.")
Genre = input("Quel est votre sexe ? (Pour Homme entrez M, pour Femme entrez F, et pour un autre type entrez O) : ") data.at[student_index, 'Telephone'] = telephone
if Genre_pattern.match(Genre): break # Exit the loop if the telephone number is valid
print("Le genre est valide.") else:
break # Sortir de la boucle si le genre est valide print("The telephone number is not valid. Make sure to follow the requested format.")
else: elif field_to_modify == 7:
print("Le genre n'est pas valide. Assurez-vous de suivre le format demandé.") while True:
elif field_to_modify == 9 : email = input("Enter the university email (@student.uclouvain.be): ")
while True: if email_pattern.match(email):
Academic_year = input("Quelle est votre année académique ? (BAC1/BAC2/BAC3/MA1/MA2) : ") print("The email is valid.")
if Academic_year_pattern.match(Academic_year): data.at[student_index, 'Email'] = email
print("L'année académique est valide.") break # Exit the loop if the email is valid
break # Sortir de la boucle si l'année académique est valide else:
else: print("The email is not valid. Make sure to follow the requested format.")
print("L'année académique n'est pas valide. Assurez-vous de suivre le format demandé.") elif field_to_modify == 8:
while True:
gender = input("What is your gender? (For Male enter M, for Female enter F, and for other type enter O): ")
elif field_to_modify == 11: # Courses and grades if gender_pattern.match(gender):
print("Courses already passed and their grade:\n") print("The gender is valid.")
for course, grade in data.iloc[student_index].items(): data.at[student_index, 'Gender'] = gender
if course not in field_mapping.values(): break # Exit the loop if the gender is valid
print(f"{course}: {grade}") else:
print("The gender is not valid. Make sure to follow the requested format.")
while True: elif field_to_modify == 9:
course_to_modify = input("Entrez le cours que vous souhaitez modifier : ") while True:
if course_to_modify in data.columns: # Le cours a été trouvé, vous pouvez continuer avec le reste de votre code academic_year = input("What is your academic year? (BAC1/BAC2/BAC3/MA1/MA2): ")
print("Le cours spécifié a été trouvé.") # Ajoutez ici le reste de votre code pour traiter le cours if academic_year_pattern.match(academic_year):
break # Sortir de la boucle puisque le cours a été trouvé print("The academic year is valid.")
else: data.at[student_index, 'Academic Year'] = academic_year
print("Le cours spécifié n'a pas été trouvé. Veuillez en sélectionner un nouveau.") break # Exit the loop if the academic year is valid
else:
new_grade = input(f"Entrez la nouvelle note pour {course_to_modify} : ") print("The academic year is not valid. Make sure to follow the requested format.")
while not new_grade.isdigit() or int(new_grade) not in range(0, 21): elif field_to_modify == 11: # Courses and grades
print("La note doit être un nombre entier entre 0 et 20.") print("Courses already passed and their grade:\n")
new_grade = input(f"Entrez la nouvelle note pour {course_to_modify} : ") for course, grade in data.iloc[student_index].items():
if course not in field_mapping.values():
# Update the grade print(f"{course}: {grade}")
data.at[student_index, course_to_modify] = int(new_grade)
elif field_to_modify == 12 : while True:
while True: course_to_modify = input("Enter the course you want to modify: ")
Campus = input("Entrez 'Louvain-la-Neuve' ou 'Mons' en fonction du campus : ") if course_to_modify in data.columns: # The course has been found, you can continue with the rest of your code
if Campus_pattern.match(Campus): print("The specified course has been found.")
print("Le choix du campus est valide.") break # Exit the loop since the course has been found
break # Sortir de la boucle si le choix du campus est valide else:
else: print("The specified course has not been found. Please select a new one.")
print("Le choix du campus n'est pas valide. Assurez-vous de suivre le format demandé.")
new_grade = input(f"Enter the new grade for {course_to_modify}: ")
else: while not new_grade.isdigit() or int(new_grade) not in range(0, 21):
new_value = input(f"Entrez la nouvelle valeur pour le champ sélectionné : ") print("The grade must be an integer between 0 and 20.")
data.at[student_index, field_mapping[field_to_modify]] = new_value new_grade = input(f"Enter the new grade for {course_to_modify}: ")
# Update the grade
data.at[student_index, course_to_modify] = int(new_grade)
elif field_to_modify == 12:
while True:
campus = input("Enter 'Louvain-la-Neuve' or 'Mons' depending on the campus: ")
if campus_pattern.match(campus):
print("The campus choice is valid.")
data.at[student_index, 'Campus'] = campus
break # Exit the loop if the campus choice is valid
else:
print("The campus choice is not valid. Make sure to follow the requested format.")
else:
new_value = input(f"Enter the new value for the selected field: ")
data.at[student_index, field_mapping[field_to_modify]] = new_value
# Save the modified data to the Excel file # Save the modified data to the Excel file
data.to_excel(file_path, index=False) data.to_excel(file_path, index=False)
print("Modification effectuée avec succès.") print("Modification successfully done.")
# Mapping for field names to DataFrame column names # Mapping for field names to DataFrame column names
field_mapping = { field_mapping = {
1: 'Name', 1: 'Name',
2: 'Surname', 2: 'Surname',
...@@ -337,367 +346,354 @@ field_mapping = { ...@@ -337,367 +346,354 @@ field_mapping = {
5: 'Address', 5: 'Address',
6: 'Telephone', 6: 'Telephone',
7: 'Email', 7: 'Email',
8: 'Genre', 8: 'Gender',
9: 'Academic Year', 9: 'Academic Year',
10: 'Curriculum', 10: 'Curriculum',
12: 'Campus' 12: 'Campus'
} }
# DELETE def delete(data):
def supprimer(data): matricule_to_delete = input("Enter the matricule of the student you want to delete: ")
matricule_to_delete = input("Entrez le matricule de l'étudiant que vous souhaitez supprimer : ")
student_index = data[data['Matricule'] == matricule_to_delete.lower()].index.tolist() student_index = data[data['Matricule'] == matricule_to_delete.lower()].index.tolist()
if not student_index: if not student_index:
print("Aucun étudiant n'a été trouvé avec le matricule que vous avez spécifié.") print("No student found with the specified matricule.")
return return
student_index = student_index[0] student_index = student_index[0]
print(f"\nSuppression de l'étudiant avec le matricule {matricule_to_delete} :\n") print(f"\nDeleting the student with matricule {matricule_to_delete}:\n")
# Afficher les détails de l'étudiant avant la suppression # Display the details of the student before deletion
print("Détails de l'étudiant avant suppression :") print("Details of the student before deletion:")
print(data.iloc[student_index]) print(data.iloc[student_index])
confirmation = input("Voulez-vous vraiment supprimer cet étudiant ? (OUI/NON) ").upper() confirmation = input("Do you really want to delete this student? (YES/NO) ").upper()
if confirmation == "OUI": if confirmation == "YES":
# Supprimer l'étudiant # Delete the student
data = data.drop(index=student_index) data = data.drop(index=student_index)
# Sauvegarder les données modifiées dans le fichier Excel # Save the modified data to the Excel file
data.to_excel(file_path, index=False) data.to_excel(file_path, index=False)
print("Suppression effectuée avec succès.") print("Deletion successful.")
else: else:
print("Suppression annulée.") print("Deletion canceled.")
# FIND # FIND
def trouver_etudiant(data): def find_student(data):
critere_recherche = input("Entrez le critère de recherche (Nom/Prénom/Matricule) : ").capitalize() search_criteria = input("Enter the search criteria (Name/Surname/Matricule): ").capitalize()
if critere_recherche == "Nom": if search_criteria == "Name":
nom_recherche = input("Entrez le nom de l'étudiant : ") name_search = input("Enter the name of the student: ")
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)] results = data[data['Name'].str.contains(name_search, case=False, na=False)]
elif critere_recherche == "Prénom": elif search_criteria == "Surname":
prenom_recherche = input("Entrez le prénom de l'étudiant : ") surname_search = input("Enter the surname of the student: ")
resultats = data[data['Surname'].str.contains(prenom_recherche, case=False, na=False)] results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
elif critere_recherche == "Matricule": elif search_criteria == "Matricule":
matricule_recherche = input("Entrez le matricule de l'étudiant : ") matricule_search = input("Enter the matricule of the student: ")
resultats = data[data['Matricule'].str.contains(matricule_recherche, case=False, na=False)] results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
else: else:
print("Critère de recherche invalide.") print("Invalid search criteria.")
return return
if resultats.empty: if results.empty:
print("Aucun étudiant trouvé avec les critères spécifiés.") print("No student found with the specified criteria.")
else: else:
print("Étudiant(s) trouvé(s) :") print("Student(s) found:")
for index, row in resultats.iterrows(): for index, row in results.iterrows():
print(f"Nom: {row['Name']}, Prénom: {row['Surname']}, Matricule: {row['Matricule']}") print(f"Name: {row['Name']}, Surname: {row['Surname']}, Matricule: {row['Matricule']}")
# SHOW # SHOW
def filter_students(data):
def filtrer(data):
if data.empty: if data.empty:
print("La liste des étudiants est vide.") print("The list of students is empty.")
else: else:
print("\nListe des étudiants :") print("\nList of students:")
for index, row in data.iterrows(): for index, row in data.iterrows():
print(f"Nom: {row['Name']}, Prénom: {row['Surname']}, Matricule: {row['Matricule']}") print(f"Name: {row['Name']}, Surname: {row['Surname']}, Matricule: {row['Matricule']}")
# Utilisation de la fonction exporter_liste_etudiants_filtree_excel # Using the function export_filtered_student_list_to_excel
# exporter_liste_etudiants_filtree_excel(data, 'liste_etudiants_filtree.xlsx') # export_filtered_student_list_to_excel(data, 'filtered_student_list.xlsx')
""" """
print('To filter students, enter SCREEN')
print('To export the list to an Excel document, enter EXPORT')
print('To read the list, enter READ')
choice = input("")
if choice == "SCREEN":
filter_students(data)
elif choice == "EXPORT":
export(data)
elif choice == "READ":
read(data)
"""
def filter_students(data):
show_list = input("Do you want to see the list of students? YES/NO")
if show_list == "YES":
for index, row in data.iterrows():
print(f"Name: {row['Name']}, Surname: {row['Surname']}, Matricule: {row['Matricule']}")
print('Pour Filtrer les élèves, entrez SCREEN') export_choice = input("Do you want to export the list? YES/NO")
print('Pour exporter la liste en document excel, entrez EXPORT')
print('Pour lire la liste, entrez READ') if export_choice == "YES":
montre = input("") try:
if montre == "SCREEN" : data.to_excel(excel_file_path, index=False)
filtrer(data) print(f"The list of students has been successfully exported to {excel_file_path}.")
elif montre == "EXPORT" : except Exception as e:
exporter(data) print(f"Error exporting to Excel: {e}")
elif montre == "READ" :
lire(data) read_choice = input("Do you want to read the exported list? YES/NO")
if read_choice == "YES":
try:
os.system(f"start excel {excel_file_path}")
except Exception as e:
print(f"Error opening the Excel file: {e}")
return open_excel(excel_file_path)
"""
def show(data):
a = input("Voulez-vous voir la liste des étudiants ? OUI/NON")
if a == "OUI" :
for index, row in data.iterrows():
print(f"Nom: {row['Name']}, Prénom: {row['Surname']}, Matricule: {row['Matricule']}")
b = input("Voulez-vous exporter la liste ? OUI/NON")
if b == "OUI" :
try:
data.to_excel(page_excel, index=False)
print(f"La liste des étudiants a été exportée avec succès vers {page_excel}.")
except Exception as e:
print(f"Erreur lors de l'exportation vers Excel : {e}")
c = input("Voulez-vous lire la liste exportée ? OUI/NON")
if c == "OUI" :
try:
os.system(f"start excel {page_excel}")
except Exception as e:
print(f"Erreur lors de l'ouverture du fichier Excel : {e}")
return ouvrir_excel(page_excel)
return return
return
return return
def ouvrir_excel(page_excel): def open_excel(excel_file_path):
try: try:
os.system(f"start excel {page_excel}") os.system(f"start excel {excel_file_path}")
except Exception as e: except Exception as e:
print(f"Erreur lors de l'ouverture du fichier Excel : {e}") print(f"Error opening the Excel file: {e}")
# SORTING # SORTING
def trier(data) : def sort(data):
print('1. Trier par ordre alphabétique croissant') print('1. Sort in ascending alphabetical order')
print('2. Trier par ordre alphabétique décroissant') print('2. Sort in descending alphabetical order')
print('3. Trier par date de naissance') print('3. Sort by date of birth')
print('4. Trier par age') print('4. Sort by age')
print('5. Trier par matricule') print('5. Sort by matricule')
print('6. Trier par année académique') print('6. Sort by academic year')
print('7. Obtenir toutes les personnes qui ont réussi un cours') print('7. Get all people who passed a course')
print('8. Obtenir toutes les personnes qui ont raté le cours') print('8. Get all people who failed a course')
print('9. Obtenir tous les étudiants de bachelier') print('9. Get all Bachelor students')
print('10. Obtenir tous les étudiants de master') print('10. Get all Master students')
sorting = input("") sorting_choice = input("")
if sorting == "1" : if sorting_choice == "1":
tri_asc(data) sort_ascending(data)
elif sorting == "2" : elif sorting_choice == "2":
tri_desc(data) sort_descending(data)
elif sorting == "3" : elif sorting_choice == "3":
tri_date(data) sort_by_date(data)
elif sorting == "4" : elif sorting_choice == "4":
tri_age(data) sort_by_age(data)
elif sorting == "5" : elif sorting_choice == "5":
tri_matricule(data) sort_by_matricule(data)
elif sorting == "6" : elif sorting_choice == "6":
tri_annee(data) sort_by_academic_year(data)
elif sorting == "7" : elif sorting_choice == "7":
tri_reussi(data) sort_passed(data)
elif sorting == "8" : elif sorting_choice == "8":
tri_rate(data) sort_failed(data)
elif sorting == "9" : elif sorting_choice == "9":
tri_bac(data) sort_bachelor(data)
elif sorting == "10" : elif sorting_choice == "10":
tri_master(data) sort_master(data)
return return
def tri_asc(data): def sort_ascending(data):
if 'Name' not in data.columns: if 'Name' not in data.columns:
print("La colonne 'Name' n'existe pas dans le DataFrame.") print("The 'Name' column does not exist in the DataFrame.")
return return
# Trier le DataFrame par la colonne 'Name' # Sort the DataFrame by the 'Name' column
data_trie = data.sort_values(by='Name', ascending=True) sorted_data = data.sort_values(by='Name', ascending=True)
# Afficher la liste triée
print("\nListe des étudiants triée par ordre alphabétique (croissant) :")
for index, row in data_trie.iterrows():
print(f"Nom: {row['Name']}, Prénom: {row['Surname']}, Matricule: {row['Matricule']}")
# Exemple d'utilisation
# Remplacez 'data' par le nom de votre DataFrame
# Display the sorted list
print("\nList of students sorted in alphabetical order (ascending):")
for index, row in sorted_data.iterrows():
print(f"Name: {row['Name']}, Surname: {row['Surname']}, Matricule: {row['Matricule']}")
# Example usage
# Replace 'data' with the name of your DataFrame
# STATS
#STATS def statistics(data):
print('1. Get basic statistics')
print('2. Get all student grades')
print('3. Get all grades for a course')
print('4. Export all statistics')
def stats(data): while True:
print('1. Avoir les statistiques de bases') stats_choice = input("Enter the number of what you want to do: ")
print('2. Avoir toutes les notes des étudiants') if stats_choice.isdigit():
print('3. Avoir toutes les notes des étudiants dans un cours') stats_int = int(stats_choice)
print('4. Exporter toutes les statistiques') if 1 <= stats_int <= 4:
while True: print("The choice is valid.")
stats = input("Entrez le numéro de ce que vous voulez faire : ") # Vérifier si la commande est un entier break
if stats.isdigit(): # Convertir la commande en entier else:
stats_int = int(stats) # Vérifier si la commande est entre 1 et 8 print("The choice must be one of those proposed.")
if 1 <= stats_int <= 8:
print("La commande est valide.") if stats_choice == "1":
break # Sortir de la boucle si la commande est valide basic_stats(data)
else: elif stats_choice == "2":
print("La commande doit être comprise dans celles proposées.") all_grades(data)
if stats == "1" : elif stats_choice == "3":
stats_base(data) course_grades(data)
elif stats == "2" : elif stats_choice == "4":
stats_grade(data) export_stats(data)
elif stats == "3" :
stats_cours(data) def basic_stats(data):
elif stats == "4" : search_criteria = input("Enter the search criteria for student statistics (Name/Surname/Matricule): ").capitalize()
stats_export(data)
if search_criteria == "Name":
def stats_base(data): name_search = input("Enter the name of the student: ")
critere_recherche = input("Entrez le critère de recherche des statistiques de l'étudiant (Nom/Prénom/Matricule) : ").capitalize() results = data[data['Name'].str.contains(name_search, case=False, na=False)]
elif search_criteria == "Surname":
if critere_recherche == "Nom": surname_search = input("Enter the surname of the student: ")
nom_recherche = input("Entrez le nom de l'étudiant : ") results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)] elif search_criteria == "Matricule":
elif critere_recherche == "Prénom": matricule_search = input("Enter the matricule of the student: ")
prenom_recherche = input("Entrez le prénom de l'étudiant : ") results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
resultats = data[data['Surname'].str.contains(prenom_recherche, case=False, na=False)]
elif critere_recherche == "Matricule":
matricule_recherche = input("Entrez le matricule de l'étudiant : ")
resultats = data[data['Matricule'].str.contains(matricule_recherche, case=False, na=False)]
else: else:
print("Critère de recherche invalide.") print("Invalid search criteria.")
return return
notes_columns = resultats.select_dtypes(include=['number']).columns numeric_columns = results.select_dtypes(include=['number']).columns
for index, row in resultats.iterrows(): for index, row in results.iterrows():
student_name = f"{row['Name']} {row['Surname']}" student_name = f"{row['Name']} {row['Surname']}"
student_notes = [row[column] for column in notes_columns if not pd.isnull(row[column])] student_grades = [row[column] for column in numeric_columns if not pd.isnull(row[column])]
if student_notes: if student_grades:
lowest_grade = min(student_notes) lowest_grade = min(student_grades)
highest_grade = max(student_notes) highest_grade = max(student_grades)
average_grade = statistics.mean(student_notes) average_grade = statistics.mean(student_grades)
median_grade = statistics.median(student_notes) median_grade = statistics.median(student_grades)
std_deviation = statistics.stdev(student_notes) std_deviation = statistics.stdev(student_grades)
print(f"\nStatistiques pour l'étudiant {student_name}:") print(f"\nStatistics for student {student_name}:")
print(f"Note la plus basse : {lowest_grade}") print(f"Lowest grade: {lowest_grade}")
print(f"Note la plus élevée : {highest_grade}") print(f"Highest grade: {highest_grade}")
print(f"Moyenne des notes : {average_grade}") print(f"Average grade: {average_grade}")
print(f"Médiane des notes : {median_grade}") print(f"Median grade: {median_grade}")
print(f"Écart-type des notes : {std_deviation}") print(f"Standard deviation of grades: {std_deviation}")
else: else:
print(f"\nAucune note trouvée pour l'étudiant {student_name}.") print(f"\nNo grades found for student {student_name}.")
def all_grades(data):
search_criteria = input("Enter the search criteria for student grades (Name/Surname/Matricule): ").capitalize()
def stats_grade(data): if search_criteria == "Name":
critere_recherche = input("Entrez le critère de recherche des statistiques de l'étudiant (Nom/Prénom/Matricule) : ").capitalize() name_search = input("Enter the name of the student: ")
results = data[data['Name'].str.contains(name_search, case=False, na=False)]
if critere_recherche == "Nom": elif search_criteria == "Surname":
nom_recherche = input("Entrez le nom de l'étudiant : ") surname_search = input("Enter the surname of the student: ")
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)] results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
elif critere_recherche == "Prénom": elif search_criteria == "Matricule":
prenom_recherche = input("Entrez le prénom de l'étudiant : ") matricule_search = input("Enter the matricule of the student: ")
resultats = data[data['Surname'].str.contains(prenom_recherche, case=False, na=False)] results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
elif critere_recherche == "Matricule":
matricule_recherche = input("Entrez le matricule de l'étudiant : ")
resultats = data[data['Matricule'].str.contains(matricule_recherche, case=False, na=False)]
else: else:
print("Critère de recherche invalide.") print("Invalid search criteria.")
return return
etudiant = data[data['Matricule'].str.contains(matricule_recherche, case=False, na=False)] student = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
if etudiant.empty: if student.empty:
print(f"Aucun étudiant trouvé avec le matricule {matricule_recherche}.") print(f"No student found with matricule {matricule_search}.")
return return
# Sélection des colonnes contenant les notes # Select columns containing grades
colonnes_notes = etudiant.select_dtypes(include=['number']).columns grade_columns = student.select_dtypes(include=['number']).columns
# Affichage des notes de l'étudiant
print(f"Notes de l'étudiant avec le matricule {matricule_recherche} :")
for colonne in colonnes_notes:
if not pd.isnull(etudiant[colonne].values[0]):
print(f"{colonne}: {etudiant[colonne].values[0]}")
# Display student's grades
print(f"Grades for student with matricule {matricule_search}:")
for column in grade_columns:
if not pd.isnull(student[column].values[0]):
print(f"{column}: {student[column].values[0]}")
def course_grades(data):
def stats_cours(data): numeric_columns = data.select_dtypes(include=['number']).columns.tolist()
print("Here is the list of courses:")
for column in numeric_columns:
print(column)
colonnes_numeriques = data.select_dtypes(include=['number']).columns.tolist() course_name = input(print("For which course do you want to display grades?"))
print("Voici la liste des cours : ")
for colonne in colonnes_numeriques:
print(colonne)
# Vérifier si le cours existe dans les colonnes du DataFrame
nom_cours = input(print("Pour quel cours voulez-vous afficher les notes ?"))
if nom_cours not in data.columns: if course_name not in data.columns:
print(f"Le cours spécifié ({nom_cours}) n'a pas été trouvé.") print(f"The specified course ({course_name}) was not found.")
return return
# Filtrer les étudiants qui ont participé à ce cours (note non nulle) # Filter students who participated in this course (non-null grade)
etudiants_cours = data[data[nom_cours].notnull()] students_in_course = data[data[course_name].notnull()]
if etudiants_cours.empty: if students_in_course.empty:
print(f"Aucun étudiant n'a participé au cours {nom_cours}.") print(f"No student participated in the course {course_name}.")
return return
# Afficher les notes des étudiants pour le cours spécifié # Display grades of students for the specified course
print(f"Notes des étudiants pour le cours {nom_cours} :") print(f"Grades of students for the course {course_name}:")
for index, row in etudiants_cours.iterrows(): for index, row in students_in_course.iterrows():
print(f"Matricule: {row['Matricule']}, Note: {row[nom_cours]}") print(f"Matricule: {row['Matricule']}, Grade: {row[course_name]}")
def export_stats(data):
def stats_export(data) : return
return
# Exemple d'utilisation
# Assurez-vous que vous avez déjà défini et chargé votre DataFrame 'data' avant d'appeler cette fonction
# Remplacez 'Nom_du_Cours' par le nom réel du cours que vous recherchez
# afficher_notes_cours(data, 'Nom_du_Cours')
# Example of usage
# Make sure you have defined and loaded your DataFrame 'data' before calling this function
# Replace 'Course_Name' with the actual name of the course you are looking for
# display_course_grades(data, 'Course_Name')
# Action # Action
def action() : def action():
print("Que voulez-vous faire ?\n Ci-dessous, vous trouverez ce qu'il est possible de faire suivi des commandes à taper.\n") print("What do you want to do?\n Below, you will find what is possible followed by the commands to type.\n")
print("1. Inscrire un étudiant") print("1. Register a student")
print("2. Modifier un ou plusieurs champs") print("2. Modify one or more fields")
print("3. Supprimer un élève") print("3. Delete a student")
print("4. Trouver un élève") print("4. Find a student")
print("5. Voir") print("5. Show")
print("6. Trier, montrer ou exporter la liste") print("6. Sort, display, or export the list")
print("7. Voir les statistiques") print("7. View statistics")
print("8. Arreter le programme") print("8. Stop the program")
while True: while True:
commande = input("Entrez le numéro de ce que vous voulez faire : ") # Vérifier si la commande est un entier command = input("Enter the number of what you want to do: ") # Check if the command is an integer
if commande.isdigit(): # Convertir la commande en entier if command.isdigit(): # Convert the command to an integer
commande_int = int(commande) # Vérifier si la commande est entre 1 et 8 command_int = int(command) # Check if the command is between 1 and 8
if 1 <= commande_int <= 8: if 1 <= command_int <= 8:
print("La commande est valide.") print("The command is valid.")
break # Sortir de la boucle si la commande est valide break # Exit the loop if the command is valid
else: else:
print("La commande doit être comprise dans celles proposées.") print("The command must be one of those proposed.")
if commande == "1" :
enregistrer_eleve(data) if command == "1":
elif commande == "2" : register_student(data)
modifier(data) elif command == "2":
elif commande == "3" : modify(data)
supprimer(data) elif command == "3":
elif commande == "4" : delete(data)
trouver_etudiant(data) elif command == "4":
elif commande == "5" : find_student(data)
show(data) elif command == "5":
elif commande == "6" : show(data)
trier(data) elif command == "6":
elif commande == "7" : sort(data)
stats(data) elif command == "7":
elif commande == "8" : statistics(data)
return False elif command == "8":
return False
menu = [] menu = []
while True: while True:
rep = action() response = action()
if rep is False: if response is False:
break break
else: else:
if rep == True: if response == True:
menu = [] menu = []
else: else:
menu.append(rep) menu.append(response)
# DATA BASE GENERATING
import pandas as pd import pandas as pd
import random import random
# Liste de noms et prénoms
noms = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', firstname_of_students = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor',
'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson',
'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King', 'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King',
'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter', 'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter',
...@@ -27,7 +29,7 @@ noms = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wi ...@@ -27,7 +29,7 @@ noms = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wi
'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George', 'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George',
'Jacobs', 'Reid', 'Kim', 'Fuller', 'Lynch', 'Dean', 'Gilbert', 'Garrett', 'Romero', 'Welch'] 'Jacobs', 'Reid', 'Kim', 'Fuller', 'Lynch', 'Dean', 'Gilbert', 'Garrett', 'Romero', 'Welch']
prenoms = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Isabella', 'Sophia', 'Jackson', 'Mia', 'Lucas', last_name_of_students = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Isabella', 'Sophia', 'Jackson', 'Mia', 'Lucas',
'Aiden', 'Ethan', 'Luna', 'Mason', 'Harper', 'Evelyn', 'Oliver', 'Aria', 'Amelia', 'Caden', 'Aiden', 'Ethan', 'Luna', 'Mason', 'Harper', 'Evelyn', 'Oliver', 'Aria', 'Amelia', 'Caden',
'Grayson', 'Charlotte', 'Chloe', 'Ella', 'Sebastian', 'Carter', 'Abigail', 'Scarlett', 'Madison', 'Grayson', 'Charlotte', 'Chloe', 'Ella', 'Sebastian', 'Carter', 'Abigail', 'Scarlett', 'Madison',
'Lily', 'Avery', 'Ella', 'Aubrey', 'Mila', 'Layla', 'Riley', 'Zoe', 'Sofia', 'Jackson', 'Liam', 'Lily', 'Avery', 'Ella', 'Aubrey', 'Mila', 'Layla', 'Riley', 'Zoe', 'Sofia', 'Jackson', 'Liam',
...@@ -51,7 +53,7 @@ prenoms = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Isabella', 'Sophia', 'Jacks ...@@ -51,7 +53,7 @@ prenoms = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Isabella', 'Sophia', 'Jacks
'Eva', 'Layla', 'Aiden', 'Amelia', 'Chloe', 'Levi', 'Lillian', 'Liam', 'Zoey', 'Hazel', 'Carter', 'Eva', 'Layla', 'Aiden', 'Amelia', 'Chloe', 'Levi', 'Lillian', 'Liam', 'Zoey', 'Hazel', 'Carter',
'Grace', 'Peyton', 'Julian', 'Eliana', 'Eva', 'Harper', 'Henry', 'Olivia', 'Lily', 'Liam', 'Abigail'] 'Grace', 'Peyton', 'Julian', 'Eliana', 'Eva', 'Harper', 'Henry', 'Olivia', 'Lily', 'Liam', 'Abigail']
annees = ['BAC1', 'BAC2', 'BAC3', 'MA1', 'MA2'] school_years = ['BAC1', 'BAC2', 'BAC3', 'MA1', 'MA2']
place_of_birth = ['Mons', 'Charleroi', 'Tournai', 'La Louvière', 'Namur', 'Nivelles', 'Wavre', "Braine-l'Alleud", 'Waterloo', 'Louvain-la-Neuve', place_of_birth = ['Mons', 'Charleroi', 'Tournai', 'La Louvière', 'Namur', 'Nivelles', 'Wavre', "Braine-l'Alleud", 'Waterloo', 'Louvain-la-Neuve',
...@@ -60,125 +62,129 @@ place_of_birth = ['Mons', 'Charleroi', 'Tournai', 'La Louvière', 'Namur', 'Nive ...@@ -60,125 +62,129 @@ place_of_birth = ['Mons', 'Charleroi', 'Tournai', 'La Louvière', 'Namur', 'Nive
'Tubize', 'Nivelles', 'Genappe', 'Jodoigne', 'Ottignies', 'La Hulpe', 'Court-Saint-Étienne', 'Rebecq', 'Wavre', 'Waterloo', 'Tubize', 'Nivelles', 'Genappe', 'Jodoigne', 'Ottignies', 'La Hulpe', 'Court-Saint-Étienne', 'Rebecq', 'Wavre', 'Waterloo',
'Lasne', 'Rixensart', 'Rosières', 'Ittre', 'Braine-le-Château', 'Chaumont-Gistoux', 'Walhain', 'Mont-Saint-Guibert', 'Beauvechain', 'Hélécine'] 'Lasne', 'Rixensart', 'Rosières', 'Ittre', 'Braine-le-Château', 'Chaumont-Gistoux', 'Walhain', 'Mont-Saint-Guibert', 'Beauvechain', 'Hélécine']
noms_rues = ['Rue de la Liberté', 'Avenue des Roses', 'Chaussée de Bruxelles', 'Rue du Commerce', 'Avenue du Parc', 'Rue Saint-Pierre', 'Chemin des Cerisiers', 'Boulevard des Étoiles', 'Avenue de la Gare', 'Rue des Champs', streets = ['Rue de la Liberté', 'Avenue des Roses', 'Chaussée de Bruxelles', 'Rue du Commerce', 'Avenue du Parc', 'Rue Saint-Pierre', 'Chemin des Cerisiers', 'Boulevard des Étoiles', 'Avenue de la Gare', 'Rue des Champs',
'Chaussée de Namur', 'Rue de la Paix', 'Avenue des Lilas', 'Rue de la Fontaine', 'Chemin du Moulin', 'Boulevard des Arts', 'Avenue des Mésanges', 'Rue des Orangers', 'Chaussée de Liège', 'Rue de l\'Église', 'Chaussée de Namur', 'Rue de la Paix', 'Avenue des Lilas', 'Rue de la Fontaine', 'Chemin du Moulin', 'Boulevard des Arts', 'Avenue des Mésanges', 'Rue des Orangers', 'Chaussée de Liège', 'Rue de l\'Église',
'Avenue du Lac', 'Rue des Violettes', 'Chemin des Peupliers', 'Boulevard de la Mer', 'Rue des Platanes', 'Avenue des Acacias', 'Chaussée de Mons', 'Rue de la Rivière', 'Avenue du Soleil', 'Rue des Écoles', 'Avenue du Lac', 'Rue des Violettes', 'Chemin des Peupliers', 'Boulevard de la Mer', 'Rue des Platanes', 'Avenue des Acacias', 'Chaussée de Mons', 'Rue de la Rivière', 'Avenue du Soleil', 'Rue des Écoles',
'Chemin des Pommiers', 'Boulevard des Montagnes', 'Rue des Trois Fontaines', 'Avenue des Cèdres', 'Chaussée de Charleroi', 'Rue du Théâtre', 'Boulevard des Papillons', 'Rue des Primevères', 'Avenue des Charmes', 'Chemin des Saules', 'Chemin des Pommiers', 'Boulevard des Montagnes', 'Rue des Trois Fontaines', 'Avenue des Cèdres', 'Chaussée de Charleroi', 'Rue du Théâtre', 'Boulevard des Papillons', 'Rue des Primevères', 'Avenue des Charmes', 'Chemin des Saules',
'Rue du Palais', 'Avenue de la Plage', 'Chaussée de Waterloo', 'Rue des Amandiers', 'Boulevard du Jardin', 'Avenue des Coquelicots', 'Rue des Moulins', 'Chemin des Roses', 'Boulevard de la Forêt', 'Rue des Iris'] 'Rue du Palais', 'Avenue de la Plage', 'Chaussée de Waterloo', 'Rue des Amandiers', 'Boulevard du Jardin', 'Avenue des Coquelicots', 'Rue des Moulins', 'Chemin des Roses', 'Boulevard de la Forêt', 'Rue des Iris']
genre = ['M', 'F', 'O'] gender = ['M', 'F', 'O']
campus_localisation = ["Louvain-la-Neuve", "Mons"]
campus_loc = ["Louvain-la-Neuve", "Mons"] all_course_BAC1 = ("Anglais 1", "Fondements du droit public", "Fondements du droit de l'entreprise", "Economie", "Espagnol 1", "Comptabilité", "Informatique de gestion", "Mathématiques de gestion 1", "Statistiques et probabilités", "Pilosophie", "Psychologie", "Sociologie", "Séminaire de travail universitaire en gestion")
coursBAC1 = ("Anglais 1", "Fondements du droit public", "Fondements du droit de l'entreprise", "Economie", "Espagnol 1", "Comptabilité", "Informatique de gestion", "Mathématiques de gestion 1", "Statistiques et probabilités", "Pilosophie", "Psychologie", "Sociologie", "Séminaire de travail universitaire en gestion") all_course_BAC2 = ("Anglais 2", "Droit de l'entreprise", "Macroéconomie", "Microéconomie", "Espagnol 2", "Marketing", "Production", "Informatique et algorithmique", "Finance", "Inférences statistiques", "Mathématiques de gestion 2", "Technologies industrielles")
coursBAC2 = ("Anglais 2", "Droit de l'entreprise", "Macroéconomie", "Microéconomie", "Espagnol 2", "Marketing", "Production", "Informatique et algorithmique", "Finance", "Inférences statistiques", "Mathématiques de gestion 2", "Technologies industrielles") all_course_BAC3 = ("Anglais 3", "Economie industrielle", "Espagnol 3", "Séminaire : organisations et transformation digitale", "Management humain", "Projet entrepreneurial", "Comptabilité et contrôle de gestion", "Gestion de données", "Coding project", "Econométrie", "Recherche opérationnelle", "Optimization", "Séminaire : organisation et mutations sociales", "Questions de sciences religieuses")
coursBAC3 = ("Anglais 3", "Economie industrielle", "Espagnol 3", "Séminaire : organisations et transformation digitale", "Management humain", "Projet entrepreneurial", "Comptabilité et contrôle de gestion", "Gestion de données", "Coding project", "Econométrie", "Recherche opérationnelle", "Optimization", "Séminaire : organisation et mutations sociales", "Questions de sciences religieuses") all_course_MA1 = ("Advanced English 1", "Español avanzado 1", "Data analytics", "Projet quantitatif et gestion de projet", "Data Mining", "Nouvelles technologies et pratiques émergentes", "Web mining", "Machine learning", "Quantitative Decision Making", "Recommender Systems", "Pilotage stratégique de l'entreprise", "Séminaire on Current Managerial Issues")
all_course_MA2 = ("Advanced English 2", "Español avanzado 1", "Responsabilité sociétale de l'entreprise","Integrated Information Systems", "Mémoire", "Séminaire d'accompagnement du mémoire")
coursMA1 = ("Advanced English 1", "Español avanzado 1", "Data analytics", "Projet quantitatif et gestion de projet", "Data Mining", "Nouvelles technologies et pratiques émergentes", "Web mining", "Machine learning", "Quantitative Decision Making", "Recommender Systems", "Pilotage stratégique de l'entreprise", "Séminaire on Current Managerial Issues")
coursMA2 = ("Advanced English 2", "Español avanzado 1", "Responsabilité sociétale de l'entreprise","Integrated Information Systems", "Mémoire", "Séminaire d'accompagnement du mémoire")
# Générer des combinaisons aléatoires de noms et prénoms pour plus de 1000 personnes # Générer des combinaisons aléatoires de noms et prénoms pour plus de 1000 personnes
donnees = [] data_generated = []
number_of_students = 100
for _ in range(100): # générer des données for each in range(number_of_students): # générer des données
# nom de la personnes # nom de la personnes
nom = random.choice(noms) last_name = random.choice(last_name_of_students)
# prenom de la personnes # prenom de la personnes
prenom = random.choice(prenoms) first_name = random.choice(firstname_of_students)
# année de cours # année de cours
annee = random.choice(annees) academic_year = random.choice(school_years)
# ville de naissance de la personne # ville de naissance de la personne
ville_naissance = random.choice(place_of_birth) city_of_birth = random.choice(place_of_birth)
# attribuer un numero de téléphone à la personne # attribuer un numero de téléphone à la personne
numero_tel = [] phone_number = []
n = f"{random.randint(10000000, 99999999):08d}" n = f"{random.randint(10000000, 99999999):08d}"
if n not in numero_tel : if n not in phone_number :
numero_tel.append(n) phone_number.append(n)
numero = f"0{n[:2]}/{n[2:4]}.{n[4:6]}.{n[6:]}" phone = f"0{n[:2]}/{n[2:4]}.{n[4:6]}.{n[6:]}"
# endroit où habite la personne # endroit où habite la personne
commune = random.choice(place_of_birth) student_city = random.choice(place_of_birth)
rue = random.choice(noms_rues) student_street = random.choice(streets)
numero_maison = random.randint(1, 200) student_number_of_house = random.randint(1, 200)
adresse = f"{rue} {numero_maison}, {commune}" adress_of_student = f"{student_number_of_house} {student_street}, {student_city}"
#attribution du sexe d'une personne #attribution du sexe d'une personne
genre_de_personne = random.choice(genre) gender_of_student = random.choice(gender)
#email de la personne #email de la personne
email = f"{nom}{'.'}{prenom}{'@student.uclouvain.be'}" email_of_student = f"{first_name}{'.'}{last_name}{'@student.uclouvain.be'}"
email_format = email.lower() email_formated = email_of_student.lower()
#attribution des campus aux élèves #attribution des campus aux élèves
campus = random.choice(campus_loc) campus = random.choice(campus_localisation)
# date de naissance sachant que l'on est en 2023 donc qqn de 17 ans ne peut pas se trouver en master # date de naissance sachant que l'on est en 2023 donc qqn de 17 ans ne peut pas se trouver en master
if annee == 'BAC1': if academic_year == 'BAC1':
annee_naiss = 2005 year_of_birth = 2005
elif annee == 'BAC2': elif academic_year == 'BAC2':
annee_naiss = 2004 year_of_birth = 2004
elif annee == 'BAC3': elif academic_year == 'BAC3':
annee_naiss = 2003 year_of_birth = 2003
elif annee == 'MA1': elif academic_year == 'MA1':
annee_naiss = 2002 year_of_birth = 2002
else: else:
annee_naiss = 2001 year_of_birth = 2001
mois_naiss = random.randint(1, 12) month_of_birth = random.randint(1, 12)
jour_naiss = random.randint(1, 28) day_of_birth = random.randint(1, 28)
annee_de_naissance = f"{jour_naiss}/{mois_naiss}/{annee_naiss}" complete_date_of_birth = f"{day_of_birth}/{month_of_birth}/{year_of_birth}"
# attribution du matricule # attribution du matricule
consonnes_nom = ''.join([c for c in nom if c.lower() not in 'aeiou'])[:3] consonant_of_lastname = ''.join([c for c in last_name if c.lower() not in 'aeiou'])[:3]
consonnes_prenom = ''.join([c for c in prenom if c.lower() not in 'aeiou'])[:2] consonant_of_firstname = ''.join([c for c in first_name if c.lower() not in 'aeiou'])[:2]
derniere_consonne_nom = ''.join([c for c in prenom if c.lower() not in 'aeiou']).lower()[-1] # ne sait pas si c'est la consonne du prénom ou du nom last_consonant_of_firstname = ''.join([c for c in first_name if c.lower() not in 'aeiou']).lower()[-1] # ne sait pas si c'est la consonne du prénom ou du nom
annee_naissance_str = str(annee_naiss)[-2:] year_of_birth_string = str(year_of_birth)[-2:]
entier_aleatoire = random.randint(0, 10) random_integer = random.randint(0, 10)
matricule = f"{consonnes_nom}{consonnes_prenom}{derniere_consonne_nom}{annee_naissance_str}{entier_aleatoire}" matricule = f"{consonant_of_lastname }{consonant_of_firstname}{last_consonant_of_firstname}{year_of_birth_string}{random_integer}"
matricule = matricule.lower() matricule = matricule.lower()
#attribution des notes aléatoirement #attribution des notes aléatoirement
notes = {} grades = {}
if annee == 'MA2': if academic_year == 'MA2':
for cours in coursBAC1 + coursBAC2 + coursBAC3 + coursMA1: for courses in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 + all_course_MA1:
notes[cours] = random.randint(10, 20) # l'éléve a dû réussir ces cours pour pouvoir avoir acces en MA2 grades[courses] = random.randint(10, 20) # l'éléve a dû réussir ces cours pour pouvoir avoir acces en MA2
for cours in coursMA2 : for courses in all_course_MA2 :
notes[cours] = random.randint(0, 20) # l'éléve pourrait avoir eu entre 0 et 20 grades[courses] = random.randint(0, 20) # l'éléve pourrait avoir eu entre 0 et 20
elif annee == 'MA1': elif academic_year == 'MA1':
for cours in coursBAC1 + coursBAC2 + coursBAC3 : for courses in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 :
notes[cours] = random.randint(10, 20) grades[courses] = random.randint(10, 20)
for cours in coursMA1 : for courses in all_course_MA1 :
notes[cours] = random.randint(0, 20) grades[courses] = random.randint(0, 20)
elif annee == 'BAC3': elif academic_year == 'BAC3':
for cours in coursBAC1 + coursBAC2 : for courses in all_course_BAC1 + all_course_BAC2 :
notes[cours] = random.randint(10, 20) grades[courses] = random.randint(10, 20)
for cours in coursBAC3 : for courses in all_course_BAC3 :
notes[cours] = random.randint(0, 20) grades[courses] = random.randint(0, 20)
elif annee == 'BAC2': elif academic_year == 'BAC2':
for cours in coursBAC1 : for courses in all_course_BAC1 :
notes[cours] = random.randint(10, 20) grades[courses] = random.randint(10, 20)
for cours in coursBAC2 : for courses in all_course_BAC2 :
notes[cours] = random.randint(0, 20) grades[courses] = random.randint(0, 20)
else: else:
for cours in coursBAC1: for courses in all_course_BAC1:
notes[cours] = random.randint(0, 20) grades[courses] = random.randint(0, 20)
donnees.append({"Name": nom, "Surname": prenom, "Academic Year" : annee, "Place of Birth" : ville_naissance, "Telephone": numero, "Address": adresse, "Genre" : genre_de_personne, "Email" : email_format, "Campus" : campus, "Date of Birth" : annee_de_naissance, "Matricule" : matricule, **notes}) data_generated.append({"Name": last_name, "Surname": first_name, "Academic Year" : academic_year, "Place of Birth" : city_of_birth , "Telephone": phone, "Address": adress_of_student, "Genre" : gender_of_student, "Email" : email_formated, "Campus" : campus, "Date of Birth" : complete_date_of_birth, "Matricule" : matricule, **grades})
# génération de données qui ne peuvent pas se ressembler # génération de données qui ne peuvent pas se ressembler
...@@ -186,7 +192,7 @@ for _ in range(100): # générer des données ...@@ -186,7 +192,7 @@ for _ in range(100): # générer des données
# Créer un DataFrame pandas # Créer un DataFrame pandas
df = pd.DataFrame(donnees) df = pd.DataFrame(data_generated)
# Enregistrer le DataFrame dans un fichier Excel # Enregistrer le DataFrame dans un fichier Excel
df.to_excel("Data_Base.xlsx", index=False) df.to_excel("Data_Base.xlsx", index=False)
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter