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
import statistics
import re
file_path = '/content/Data_Base.xlsx'
data = pd.read_excel(file_path)
page_excel = 'exporter_les_noms.xlsx'
excel_file_path = 'export_names.xlsx'
menu = []
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}$')
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]+$')
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$')
Genre_pattern = re.compile(r'^[MFO]$')
Academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$')
Campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE)
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}$')
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]+$')
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$')
gender_pattern = re.compile(r'^[MFO]$')
academic_year_pattern = re.compile(r'^(BAC[123]|MA[12])$')
campus_pattern = re.compile(r'^(Louvain-la-Neuve|Mons)$', re.IGNORECASE)
# REGISTER
def enregistrer_eleve(data) :
# mise en place des patterns a respecter pour rentrer les informations
while True:
Name = input("Quel est son nom ? ") # Demander le nom à l'utilisateur
if Name_pattern.match(Name): # Vérifier si le nom correspond au format spécifié
print("Le nom est valide.")
break # Sortir de la boucle si le nom est valide
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
def register_student(data):
# Setting up the patterns to follow for entering information
while True:
Name = input("What is the student's name? ") # Ask the user for the name
if name_pattern.match(Name): # Check if the name matches the specified format
print("The name is valid.")
break # Exit the loop if the name is valid
else:
print("L'adresse n'est pas valide. Assurez-vous de suivre le format 'rue numéro, ville'.")
while True:
Telephone = input("Quel est son numéro de téléphone ? (à mettre au format 000/00.00.00) ")
if Telephone_pattern.match(Telephone):
print("Le numéro de téléphone est valide.")
break # Sortir de la boucle si le numéro de téléphone est valide
print("The name is not valid. Make sure to follow the specified format.")
while True:
Surname = input("What is the student's surname? ") # Ask the user for the surname
if name_pattern.match(Surname):
print("The surname is valid.")
break # Exit the loop if the surname is valid
else:
print("Le numéro de téléphone n'est pas valide. Assurez-vous de suivre le format demandé.")
while True:
Email = input("Entrez l'email de l'université (@student.uclouvain.be) : ")
if Email_pattern.match(Email):
print("L'email est valide.")
break # Sortir de la boucle si l'email est valide
print("The surname is not valid. Make sure to follow the specified format.")
while True:
Date_of_birth = input("Please enter a date in the format dd/mm/yyyy: ")
if date_pattern.match(Date_of_birth):
print("The date is valid.")
break # Exit the loop if the date is valid
else:
print("L'email n'est pas valide. Assurez-vous de suivre le format demandé.")
while True:
Genre = input("Quel est votre sexe ? (Pour Homme entrez M, pour Femme entrez F, et pour un autre type entrez O) : ")
if Genre_pattern.match(Genre):
print("Le genre est valide.")
break # Sortir de la boucle si le genre est valide
else:
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
print("The date is not valid. Make sure to follow the format dd/mm/yyyy.")
while True:
Place_of_birth = input("What is the city of birth? ")
if place_of_birth_pattern.match(Place_of_birth):
print("The city of birth is valid.")
break # Exit the loop if the city of birth is valid
else:
print("L'année académique n'est pas valide. Assurez-vous de suivre le format demandé.")
Courses_and_grade = {}
if Academic_year == 'MA2':
for cours in coursBAC1 + coursBAC2 + coursBAC3 + coursMA1 + coursMA2 :
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 == '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
print("The city of birth is not valid. Make sure to use only letters and spaces.")
while True:
Address = input("Please enter an address in the format 'street number, city': ")
if address_pattern.match(Address):
print("The address is valid.")
break # Exit the loop if the address is valid
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 = {
"Name": Name,
"Surname": Surname,
"Date of Birth": Date_of_Birth,
"Place of Birth": Place_of_Birth,
"Address": Address,
"Telephone": Telephone,
"Email": Email,
"Genre": Genre,
"Academic Year": Academic_year,
"Campus": Campus,
"Matricule": Matricule
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.")
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.")
register(data, Name, Surname, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus)
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():
etudiant[cours] = note
for course, grade in courses_and_grade.items():
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)
print('La personne a été enregistrée.\n')
print('The person has been registered.\n')
return
def generer_matricule(Name, Surname, Date_of_birth) :
consonnes_nom = ''.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]
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
annee_naissance_str = str(Date_of_birth)[-2:]
entier_aleatoire = random.randint(0, 10)
matricule_e = f"{consonnes_nom}{consonnes_prenom}{derniere_consonne_nom}{annee_naissance_str}{entier_aleatoire}"
def generate_matricule(name, surname, date_of_birth):
consonants_name = ''.join([c for c in name if c.lower() not in 'aeiouy'])[:3]
consonants_surname = ''.join([c for c in surname if c.lower() not in 'aeiouy'])[:2]
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
birth_year_last_two_digits = str(date_of_birth)[-2:]
random_integer = random.randint(0, 10)
matricule_e = f"{consonants_name}{consonants_surname}{last_consonant_surname}{birth_year_last_two_digits}{random_integer}"
matricule_e = matricule_e.lower()
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 :
print("Aucun étudiant n'a été trouvé avec le matricule que vous avez spécifié.")
return
student_index = student_index[0]
print(f"\nModification de l'étudiant avec le matricule {data_to_modify} :\n")
print("1. Name")
print("2. Surname")
print("3. Date of Birth")
print("4. Place of Birth")
print("5. Address")
print("6. Telephone")
print("7. Email")
print("8. Sex (M | F | O)")
print("9. Academic Year")
print("10. Curriculum")
print("11. Courses already passed and their grade")
print("12. Campus")
field_to_modify = int(input("Entrez le numéro du champ que vous souhaitez modifier : "))
field_name_to_modify = field_mapping.get(field_to_modify, None)
print(f"Vous modifiez le champ : {field_name_to_modify}")
if field_to_modify == 1: # Si le champ à modifier est le nom (Name)
while True:
Name = input("Quel est le nom que vous voulez modifier ? ")
if Name_pattern.match(Name):
print("Le nom est valide.")
# Ajoutez ici le code pour mettre à jour le champ dans vos données
break # Sortir de la boucle si le nom est valide
else:
print("Le nom n'est pas valide. Assurez-vous de suivre le format spécifié.")
elif field_to_modify == 2:
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é.")
elif field_to_modify == 3 :
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.")
elif field_to_modify == 4 :
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.")
elif field_to_modify == 5 :
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:
print("L'adresse n'est pas valide. Assurez-vous de suivre le format 'rue numéro, ville'.")
elif field_to_modify == 6 :
while True:
Telephone = input("Quel est son numéro de téléphone ? (à mettre au format 000/00.00.00) ")
if Telephone_pattern.match(Telephone):
print("Le numéro de téléphone est valide.")
break # Sortir de la boucle si le numéro de téléphone est valide
else:
print("Le numéro de téléphone n'est pas valide. Assurez-vous de suivre le format demandé.")
elif field_to_modify == 7 :
while True:
Email = input("Entrez l'email de l'université (@student.uclouvain.be) : ")
if Email_pattern.match(Email):
print("L'email est valide.")
break # Sortir de la boucle si l'email est valide
else:
print("L'email n'est pas valide. Assurez-vous de suivre le format demandé.")
elif field_to_modify == 8 :
while True:
Genre = input("Quel est votre sexe ? (Pour Homme entrez M, pour Femme entrez F, et pour un autre type entrez O) : ")
if Genre_pattern.match(Genre):
print("Le genre est valide.")
break # Sortir de la boucle si le genre est valide
else:
print("Le genre n'est pas valide. Assurez-vous de suivre le format demandé.")
elif field_to_modify == 9 :
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:
print("L'année académique n'est pas valide. Assurez-vous de suivre le format demandé.")
elif field_to_modify == 11: # Courses and grades
print("Courses already passed and their grade:\n")
for course, grade in data.iloc[student_index].items():
if course not in field_mapping.values():
print(f"{course}: {grade}")
while True:
course_to_modify = input("Entrez le cours que vous souhaitez modifier : ")
if course_to_modify in data.columns: # Le cours a été trouvé, vous pouvez continuer avec le reste de votre code
print("Le cours spécifié a été trouvé.") # Ajoutez ici le reste de votre code pour traiter le cours
break # Sortir de la boucle puisque le cours a été trouvé
else:
print("Le cours spécifié n'a pas été trouvé. Veuillez en sélectionner un nouveau.")
new_grade = input(f"Entrez la nouvelle note pour {course_to_modify} : ")
while not new_grade.isdigit() or int(new_grade) not in range(0, 21):
print("La note doit être un nombre entier entre 0 et 20.")
new_grade = input(f"Entrez la nouvelle note pour {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("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:
print("Le choix du campus n'est pas valide. Assurez-vous de suivre le format demandé.")
else:
new_value = input(f"Entrez la nouvelle valeur pour le champ sélectionné : ")
data.at[student_index, field_mapping[field_to_modify]] = new_value
def modify(data):
while True:
matricule_to_modify = input("Enter the matricule of the student you want to modify (or 'q' to quit): ")
if matricule_to_modify.lower() == 'q':
print("Operation canceled.")
break
student_index = data[data['Matricule'] == matricule_to_modify.lower()].index.tolist()
if not student_index:
print("No student found with the specified matricule.")
return
student_index = student_index[0]
print(f"\nModifying the student with matricule {matricule_to_modify}:\n")
print("1. Name")
print("2. Surname")
print("3. Date of Birth")
print("4. Place of Birth")
print("5. Address")
print("6. Telephone")
print("7. Email")
print("8. Sex (M | F | O)")
print("9. Academic Year")
print("10. Curriculum")
print("11. Courses already passed and their grade")
print("12. Campus")
field_to_modify = int(input("Enter the number of the field you want to modify: "))
field_name_to_modify = field_mapping.get(field_to_modify, None)
print(f"You are modifying the field: {field_name_to_modify}")
if field_to_modify == 1: # If the field to modify is the name (Name)
while True:
name = input("What is the name you want to modify? ")
if name_pattern.match(name):
print("The name is valid.")
data.at[student_index, 'Name'] = name
break # Exit the loop if the name is valid
else:
print("The name is not valid. Make sure to follow the specified format.")
elif field_to_modify == 2:
while True: # Ask the user for the surname
surname = input("What is the surname? ")
if name_pattern.match(surname):
print("The surname is valid.")
data.at[student_index, 'Surname'] = surname
break # Exit the loop if the surname is valid
else:
print("The surname is not valid. Make sure to follow the specified format.")
elif field_to_modify == 3:
while True:
date_of_birth = input("Please enter a date in the format dd/mm/yyyy: ")
if date_pattern.match(date_of_birth):
print("The date is valid.")
data.at[student_index, 'Date of Birth'] = date_of_birth
break # Exit the loop if the date is valid
else:
print("The date is not valid. Make sure to follow the format dd/mm/yyyy.")
elif field_to_modify == 4:
while True:
place_of_birth = input("What is the city of birth? ")
if place_of_birth_pattern.match(place_of_birth):
print("The city of birth is valid.")
data.at[student_index, 'Place of Birth'] = place_of_birth
break # Exit the loop if the city of birth is valid
else:
print("The city of birth is not valid. Make sure to use only letters and spaces.")
elif field_to_modify == 5:
while True:
address = input("Please enter an address in the format 'street number, city': ")
if address_pattern.match(address):
print("The address is valid.")
data.at[student_index, 'Address'] = address
break # Exit the loop if the address is valid
else:
print("The address is not valid. Make sure to follow the format 'street number, city'.")
elif field_to_modify == 6:
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.")
data.at[student_index, 'Telephone'] = telephone
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.")
elif field_to_modify == 7:
while True:
email = input("Enter the university email (@student.uclouvain.be): ")
if email_pattern.match(email):
print("The email is valid.")
data.at[student_index, 'Email'] = email
break # Exit the loop if the email is valid
else:
print("The email is not valid. Make sure to follow the requested format.")
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): ")
if gender_pattern.match(gender):
print("The gender is valid.")
data.at[student_index, 'Gender'] = gender
break # Exit the loop if the gender is valid
else:
print("The gender is not valid. Make sure to follow the requested format.")
elif field_to_modify == 9:
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.")
data.at[student_index, 'Academic Year'] = academic_year
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.")
elif field_to_modify == 11: # Courses and grades
print("Courses already passed and their grade:\n")
for course, grade in data.iloc[student_index].items():
if course not in field_mapping.values():
print(f"{course}: {grade}")
while True:
course_to_modify = input("Enter the course you want to modify: ")
if course_to_modify in data.columns: # The course has been found, you can continue with the rest of your code
print("The specified course has been found.")
break # Exit the loop since the course has been found
else:
print("The specified course has not been found. Please select a new one.")
new_grade = input(f"Enter the new grade for {course_to_modify}: ")
while not new_grade.isdigit() or int(new_grade) not in range(0, 21):
print("The grade must be an integer between 0 and 20.")
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
data.to_excel(file_path, index=False)
print("Modification effectuée avec succès.")
# Save the modified data to the Excel file
data.to_excel(file_path, index=False)
print("Modification successfully done.")
# Mapping for field names to DataFrame column names
# Mapping for field names to DataFrame column names
field_mapping = {
1: 'Name',
2: 'Surname',
......@@ -337,367 +346,354 @@ field_mapping = {
5: 'Address',
6: 'Telephone',
7: 'Email',
8: 'Genre',
8: 'Gender',
9: 'Academic Year',
10: 'Curriculum',
12: 'Campus'
}
# DELETE
def supprimer(data):
matricule_to_delete = input("Entrez le matricule de l'étudiant que vous souhaitez supprimer : ")
def delete(data):
matricule_to_delete = input("Enter the matricule of the student you want to delete: ")
student_index = data[data['Matricule'] == matricule_to_delete.lower()].index.tolist()
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
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
print("Détails de l'étudiant avant suppression :")
# Display the details of the student before deletion
print("Details of the student before deletion:")
print(data.iloc[student_index])
confirmation = input("Voulez-vous vraiment supprimer cet étudiant ? (OUI/NON) ").upper()
if confirmation == "OUI":
# Supprimer l'étudiant
confirmation = input("Do you really want to delete this student? (YES/NO) ").upper()
if confirmation == "YES":
# Delete the student
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)
print("Suppression effectuée avec succès.")
print("Deletion successful.")
else:
print("Suppression annulée.")
print("Deletion canceled.")
# FIND
def trouver_etudiant(data):
critere_recherche = input("Entrez le critère de recherche (Nom/Prénom/Matricule) : ").capitalize()
if critere_recherche == "Nom":
nom_recherche = input("Entrez le nom de l'étudiant : ")
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)]
elif critere_recherche == "Prénom":
prenom_recherche = input("Entrez le prénom de l'étudiant : ")
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)]
def find_student(data):
search_criteria = input("Enter the search criteria (Name/Surname/Matricule): ").capitalize()
if search_criteria == "Name":
name_search = input("Enter the name of the student: ")
results = data[data['Name'].str.contains(name_search, case=False, na=False)]
elif search_criteria == "Surname":
surname_search = input("Enter the surname of the student: ")
results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
elif search_criteria == "Matricule":
matricule_search = input("Enter the matricule of the student: ")
results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
else:
print("Critère de recherche invalide.")
print("Invalid search criteria.")
return
if resultats.empty:
print("Aucun étudiant trouvé avec les critères spécifiés.")
if results.empty:
print("No student found with the specified criteria.")
else:
print("Étudiant(s) trouvé(s) :")
for index, row in resultats.iterrows():
print(f"Nom: {row['Name']}, Prénom: {row['Surname']}, Matricule: {row['Matricule']}")
print("Student(s) found:")
for index, row in results.iterrows():
print(f"Name: {row['Name']}, Surname: {row['Surname']}, Matricule: {row['Matricule']}")
# SHOW
def filtrer(data):
def filter_students(data):
if data.empty:
print("La liste des étudiants est vide.")
print("The list of students is empty.")
else:
print("\nListe des étudiants :")
print("\nList of students:")
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
# exporter_liste_etudiants_filtree_excel(data, 'liste_etudiants_filtree.xlsx')
# Using the function export_filtered_student_list_to_excel
# 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')
print('Pour exporter la liste en document excel, entrez EXPORT')
print('Pour lire la liste, entrez READ')
montre = input("")
if montre == "SCREEN" :
filtrer(data)
elif montre == "EXPORT" :
exporter(data)
elif montre == "READ" :
lire(data)
export_choice = input("Do you want to export the list? YES/NO")
if export_choice == "YES":
try:
data.to_excel(excel_file_path, index=False)
print(f"The list of students has been successfully exported to {excel_file_path}.")
except Exception as e:
print(f"Error exporting to Excel: {e}")
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
def ouvrir_excel(page_excel):
def open_excel(excel_file_path):
try:
os.system(f"start excel {page_excel}")
os.system(f"start excel {excel_file_path}")
except Exception as e:
print(f"Erreur lors de l'ouverture du fichier Excel : {e}")
print(f"Error opening the Excel file: {e}")
# SORTING
def trier(data) :
print('1. Trier par ordre alphabétique croissant')
print('2. Trier par ordre alphabétique décroissant')
print('3. Trier par date de naissance')
print('4. Trier par age')
print('5. Trier par matricule')
print('6. Trier par année académique')
print('7. Obtenir toutes les personnes qui ont réussi un cours')
print('8. Obtenir toutes les personnes qui ont raté le cours')
print('9. Obtenir tous les étudiants de bachelier')
print('10. Obtenir tous les étudiants de master')
sorting = input("")
if sorting == "1" :
tri_asc(data)
elif sorting == "2" :
tri_desc(data)
elif sorting == "3" :
tri_date(data)
elif sorting == "4" :
tri_age(data)
elif sorting == "5" :
tri_matricule(data)
elif sorting == "6" :
tri_annee(data)
elif sorting == "7" :
tri_reussi(data)
elif sorting == "8" :
tri_rate(data)
elif sorting == "9" :
tri_bac(data)
elif sorting == "10" :
tri_master(data)
return
def tri_asc(data):
def sort(data):
print('1. Sort in ascending alphabetical order')
print('2. Sort in descending alphabetical order')
print('3. Sort by date of birth')
print('4. Sort by age')
print('5. Sort by matricule')
print('6. Sort by academic year')
print('7. Get all people who passed a course')
print('8. Get all people who failed a course')
print('9. Get all Bachelor students')
print('10. Get all Master students')
sorting_choice = input("")
if sorting_choice == "1":
sort_ascending(data)
elif sorting_choice == "2":
sort_descending(data)
elif sorting_choice == "3":
sort_by_date(data)
elif sorting_choice == "4":
sort_by_age(data)
elif sorting_choice == "5":
sort_by_matricule(data)
elif sorting_choice == "6":
sort_by_academic_year(data)
elif sorting_choice == "7":
sort_passed(data)
elif sorting_choice == "8":
sort_failed(data)
elif sorting_choice == "9":
sort_bachelor(data)
elif sorting_choice == "10":
sort_master(data)
return
def sort_ascending(data):
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
# Trier le DataFrame par la colonne 'Name'
data_trie = 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
# Sort the DataFrame by the 'Name' column
sorted_data = data.sort_values(by='Name', ascending=True)
# 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):
print('1. Avoir les statistiques de bases')
print('2. Avoir toutes les notes des étudiants')
print('3. Avoir toutes les notes des étudiants dans un cours')
print('4. Exporter toutes les statistiques')
while True:
stats = input("Entrez le numéro de ce que vous voulez faire : ") # Vérifier si la commande est un entier
if stats.isdigit(): # Convertir la commande en entier
stats_int = int(stats) # Vérifier si la commande est entre 1 et 8
if 1 <= stats_int <= 8:
print("La commande est valide.")
break # Sortir de la boucle si la commande est valide
else:
print("La commande doit être comprise dans celles proposées.")
if stats == "1" :
stats_base(data)
elif stats == "2" :
stats_grade(data)
elif stats == "3" :
stats_cours(data)
elif stats == "4" :
stats_export(data)
def stats_base(data):
critere_recherche = input("Entrez le critère de recherche des statistiques de l'étudiant (Nom/Prénom/Matricule) : ").capitalize()
if critere_recherche == "Nom":
nom_recherche = input("Entrez le nom de l'étudiant : ")
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)]
elif critere_recherche == "Prénom":
prenom_recherche = input("Entrez le prénom de l'étudiant : ")
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)]
while True:
stats_choice = input("Enter the number of what you want to do: ")
if stats_choice.isdigit():
stats_int = int(stats_choice)
if 1 <= stats_int <= 4:
print("The choice is valid.")
break
else:
print("The choice must be one of those proposed.")
if stats_choice == "1":
basic_stats(data)
elif stats_choice == "2":
all_grades(data)
elif stats_choice == "3":
course_grades(data)
elif stats_choice == "4":
export_stats(data)
def basic_stats(data):
search_criteria = input("Enter the search criteria for student statistics (Name/Surname/Matricule): ").capitalize()
if search_criteria == "Name":
name_search = input("Enter the name of the student: ")
results = data[data['Name'].str.contains(name_search, case=False, na=False)]
elif search_criteria == "Surname":
surname_search = input("Enter the surname of the student: ")
results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
elif search_criteria == "Matricule":
matricule_search = input("Enter the matricule of the student: ")
results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
else:
print("Critère de recherche invalide.")
print("Invalid search criteria.")
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_notes = [row[column] for column in notes_columns if not pd.isnull(row[column])]
if student_notes:
lowest_grade = min(student_notes)
highest_grade = max(student_notes)
average_grade = statistics.mean(student_notes)
median_grade = statistics.median(student_notes)
std_deviation = statistics.stdev(student_notes)
print(f"\nStatistiques pour l'étudiant {student_name}:")
print(f"Note la plus basse : {lowest_grade}")
print(f"Note la plus élevée : {highest_grade}")
print(f"Moyenne des notes : {average_grade}")
print(f"Médiane des notes : {median_grade}")
print(f"Écart-type des notes : {std_deviation}")
student_grades = [row[column] for column in numeric_columns if not pd.isnull(row[column])]
if student_grades:
lowest_grade = min(student_grades)
highest_grade = max(student_grades)
average_grade = statistics.mean(student_grades)
median_grade = statistics.median(student_grades)
std_deviation = statistics.stdev(student_grades)
print(f"\nStatistics for student {student_name}:")
print(f"Lowest grade: {lowest_grade}")
print(f"Highest grade: {highest_grade}")
print(f"Average grade: {average_grade}")
print(f"Median grade: {median_grade}")
print(f"Standard deviation of grades: {std_deviation}")
else:
print(f"\nAucune note trouvée pour l'étudiant {student_name}.")
def stats_grade(data):
critere_recherche = input("Entrez le critère de recherche des statistiques de l'étudiant (Nom/Prénom/Matricule) : ").capitalize()
if critere_recherche == "Nom":
nom_recherche = input("Entrez le nom de l'étudiant : ")
resultats = data[data['Name'].str.contains(nom_recherche, case=False, na=False)]
elif critere_recherche == "Prénom":
prenom_recherche = input("Entrez le prénom de l'étudiant : ")
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)]
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()
if search_criteria == "Name":
name_search = input("Enter the name of the student: ")
results = data[data['Name'].str.contains(name_search, case=False, na=False)]
elif search_criteria == "Surname":
surname_search = input("Enter the surname of the student: ")
results = data[data['Surname'].str.contains(surname_search, case=False, na=False)]
elif search_criteria == "Matricule":
matricule_search = input("Enter the matricule of the student: ")
results = data[data['Matricule'].str.contains(matricule_search, case=False, na=False)]
else:
print("Critère de recherche invalide.")
print("Invalid search criteria.")
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:
print(f"Aucun étudiant trouvé avec le matricule {matricule_recherche}.")
if student.empty:
print(f"No student found with matricule {matricule_search}.")
return
# Sélection des colonnes contenant les notes
colonnes_notes = etudiant.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]}")
# Select columns containing grades
grade_columns = student.select_dtypes(include=['number']).columns
# 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()
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 ?"))
course_name = input(print("For which course do you want to display grades?"))
if nom_cours not in data.columns:
print(f"Le cours spécifié ({nom_cours}) n'a pas été trouvé.")
if course_name not in data.columns:
print(f"The specified course ({course_name}) was not found.")
return
# Filtrer les étudiants qui ont participé à ce cours (note non nulle)
etudiants_cours = data[data[nom_cours].notnull()]
# Filter students who participated in this course (non-null grade)
students_in_course = data[data[course_name].notnull()]
if etudiants_cours.empty:
print(f"Aucun étudiant n'a participé au cours {nom_cours}.")
if students_in_course.empty:
print(f"No student participated in the course {course_name}.")
return
# Afficher les notes des étudiants pour le cours spécifié
print(f"Notes des étudiants pour le cours {nom_cours} :")
for index, row in etudiants_cours.iterrows():
print(f"Matricule: {row['Matricule']}, Note: {row[nom_cours]}")
# Display grades of students for the specified course
print(f"Grades of students for the course {course_name}:")
for index, row in students_in_course.iterrows():
print(f"Matricule: {row['Matricule']}, Grade: {row[course_name]}")
def export_stats(data):
def stats_export(data) :
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')
return
# 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
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("1. Inscrire un étudiant")
print("2. Modifier un ou plusieurs champs")
print("3. Supprimer un élève")
print("4. Trouver un élève")
print("5. Voir")
print("6. Trier, montrer ou exporter la liste")
print("7. Voir les statistiques")
print("8. Arreter le programme")
def action():
print("What do you want to do?\n Below, you will find what is possible followed by the commands to type.\n")
print("1. Register a student")
print("2. Modify one or more fields")
print("3. Delete a student")
print("4. Find a student")
print("5. Show")
print("6. Sort, display, or export the list")
print("7. View statistics")
print("8. Stop the program")
while True:
commande = input("Entrez le numéro de ce que vous voulez faire : ") # Vérifier si la commande est un entier
if commande.isdigit(): # Convertir la commande en entier
commande_int = int(commande) # Vérifier si la commande est entre 1 et 8
if 1 <= commande_int <= 8:
print("La commande est valide.")
break # Sortir de la boucle si la commande est valide
else:
print("La commande doit être comprise dans celles proposées.")
if commande == "1" :
enregistrer_eleve(data)
elif commande == "2" :
modifier(data)
elif commande == "3" :
supprimer(data)
elif commande == "4" :
trouver_etudiant(data)
elif commande == "5" :
show(data)
elif commande == "6" :
trier(data)
elif commande == "7" :
stats(data)
elif commande == "8" :
return False
command = input("Enter the number of what you want to do: ") # Check if the command is an integer
if command.isdigit(): # Convert the command to an integer
command_int = int(command) # Check if the command is between 1 and 8
if 1 <= command_int <= 8:
print("The command is valid.")
break # Exit the loop if the command is valid
else:
print("The command must be one of those proposed.")
if command == "1":
register_student(data)
elif command == "2":
modify(data)
elif command == "3":
delete(data)
elif command == "4":
find_student(data)
elif command == "5":
show(data)
elif command == "6":
sort(data)
elif command == "7":
statistics(data)
elif command == "8":
return False
menu = []
while True:
rep = action()
if rep is False:
response = action()
if response is False:
break
else:
if rep == True:
menu = []
else:
menu.append(rep)
if response == True:
menu = []
else:
menu.append(response)
# DATA BASE GENERATING
import pandas as pd
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',
'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King',
'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter',
......@@ -27,7 +29,7 @@ noms = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wi
'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George',
'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',
'Grayson', 'Charlotte', 'Chloe', 'Ella', 'Sebastian', 'Carter', 'Abigail', 'Scarlett', 'Madison',
'Lily', 'Avery', 'Ella', 'Aubrey', 'Mila', 'Layla', 'Riley', 'Zoe', 'Sofia', 'Jackson', 'Liam',
......@@ -51,7 +53,7 @@ prenoms = ['Emma', 'Liam', 'Olivia', 'Noah', 'Ava', 'Isabella', 'Sophia', 'Jacks
'Eva', 'Layla', 'Aiden', 'Amelia', 'Chloe', 'Levi', 'Lillian', 'Liam', 'Zoey', 'Hazel', 'Carter',
'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',
......@@ -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',
'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',
'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',
'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
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 = random.choice(noms)
last_name = random.choice(last_name_of_students)
# prenom de la personnes
prenom = random.choice(prenoms)
first_name = random.choice(firstname_of_students)
# année de cours
annee = random.choice(annees)
academic_year = random.choice(school_years)
# 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
numero_tel = []
phone_number = []
n = f"{random.randint(10000000, 99999999):08d}"
if n not in numero_tel :
numero_tel.append(n)
numero = f"0{n[:2]}/{n[2:4]}.{n[4:6]}.{n[6:]}"
if n not in phone_number :
phone_number.append(n)
phone = f"0{n[:2]}/{n[2:4]}.{n[4:6]}.{n[6:]}"
# endroit où habite la personne
commune = random.choice(place_of_birth)
rue = random.choice(noms_rues)
numero_maison = random.randint(1, 200)
adresse = f"{rue} {numero_maison}, {commune}"
student_city = random.choice(place_of_birth)
student_street = random.choice(streets)
student_number_of_house = random.randint(1, 200)
adress_of_student = f"{student_number_of_house} {student_street}, {student_city}"
#attribution du sexe d'une personne
genre_de_personne = random.choice(genre)
gender_of_student = random.choice(gender)
#email de la personne
email = f"{nom}{'.'}{prenom}{'@student.uclouvain.be'}"
email_format = email.lower()
email_of_student = f"{first_name}{'.'}{last_name}{'@student.uclouvain.be'}"
email_formated = email_of_student.lower()
#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
if annee == 'BAC1':
annee_naiss = 2005
elif annee == 'BAC2':
annee_naiss = 2004
elif annee == 'BAC3':
annee_naiss = 2003
elif annee == 'MA1':
annee_naiss = 2002
if academic_year == 'BAC1':
year_of_birth = 2005
elif academic_year == 'BAC2':
year_of_birth = 2004
elif academic_year == 'BAC3':
year_of_birth = 2003
elif academic_year == 'MA1':
year_of_birth = 2002
else:
annee_naiss = 2001
year_of_birth = 2001
mois_naiss = random.randint(1, 12)
jour_naiss = random.randint(1, 28)
annee_de_naissance = f"{jour_naiss}/{mois_naiss}/{annee_naiss}"
month_of_birth = random.randint(1, 12)
day_of_birth = random.randint(1, 28)
complete_date_of_birth = f"{day_of_birth}/{month_of_birth}/{year_of_birth}"
# attribution du matricule
consonnes_nom = ''.join([c for c in nom if c.lower() not in 'aeiou'])[:3]
consonnes_prenom = ''.join([c for c in prenom 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
annee_naissance_str = str(annee_naiss)[-2:]
entier_aleatoire = random.randint(0, 10)
matricule = f"{consonnes_nom}{consonnes_prenom}{derniere_consonne_nom}{annee_naissance_str}{entier_aleatoire}"
consonant_of_lastname = ''.join([c for c in last_name if c.lower() not in 'aeiou'])[:3]
consonant_of_firstname = ''.join([c for c in first_name if c.lower() not in 'aeiou'])[:2]
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
year_of_birth_string = str(year_of_birth)[-2:]
random_integer = random.randint(0, 10)
matricule = f"{consonant_of_lastname }{consonant_of_firstname}{last_consonant_of_firstname}{year_of_birth_string}{random_integer}"
matricule = matricule.lower()
#attribution des notes aléatoirement
notes = {}
if annee == 'MA2':
for cours in coursBAC1 + coursBAC2 + coursBAC3 + coursMA1:
notes[cours] = random.randint(10, 20) # l'éléve a dû réussir ces cours pour pouvoir avoir acces en MA2
for cours in coursMA2 :
notes[cours] = random.randint(0, 20) # l'éléve pourrait avoir eu entre 0 et 20
elif annee == 'MA1':
for cours in coursBAC1 + coursBAC2 + coursBAC3 :
notes[cours] = random.randint(10, 20)
for cours in coursMA1 :
notes[cours] = random.randint(0, 20)
elif annee == 'BAC3':
for cours in coursBAC1 + coursBAC2 :
notes[cours] = random.randint(10, 20)
for cours in coursBAC3 :
notes[cours] = random.randint(0, 20)
elif annee == 'BAC2':
for cours in coursBAC1 :
notes[cours] = random.randint(10, 20)
for cours in coursBAC2 :
notes[cours] = random.randint(0, 20)
grades = {}
if academic_year == 'MA2':
for courses in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 + all_course_MA1:
grades[courses] = random.randint(10, 20) # l'éléve a dû réussir ces cours pour pouvoir avoir acces en MA2
for courses in all_course_MA2 :
grades[courses] = random.randint(0, 20) # l'éléve pourrait avoir eu entre 0 et 20
elif academic_year == 'MA1':
for courses in all_course_BAC1 + all_course_BAC2 + all_course_BAC3 :
grades[courses] = random.randint(10, 20)
for courses in all_course_MA1 :
grades[courses] = random.randint(0, 20)
elif academic_year == 'BAC3':
for courses in all_course_BAC1 + all_course_BAC2 :
grades[courses] = random.randint(10, 20)
for courses in all_course_BAC3 :
grades[courses] = random.randint(0, 20)
elif academic_year == 'BAC2':
for courses in all_course_BAC1 :
grades[courses] = random.randint(10, 20)
for courses in all_course_BAC2 :
grades[courses] = random.randint(0, 20)
else:
for cours in coursBAC1:
notes[cours] = random.randint(0, 20)
for courses in all_course_BAC1:
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
......@@ -186,7 +192,7 @@ for _ in range(100): # générer des données
# Créer un DataFrame pandas
df = pd.DataFrame(donnees)
df = pd.DataFrame(data_generated)
# Enregistrer le DataFrame dans un fichier Excel
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