diff --git a/Data_Base.xlsx b/Data_Base.xlsx index 1f39cc98688a95fbd37c3b9973f49706d96e2f3b..ff3609863d3bf4498232613c4b243f066019e719 100644 Binary files a/Data_Base.xlsx and b/Data_Base.xlsx differ diff --git a/projet_personnel/algorithme_gestion_etudiants.py b/projet_personnel/algorithme_gestion_etudiants.py index b2d39ed30c403cdc3e4a8efc4a8f93ce023ef863..bba2dfb4ebc96ebfea2b54dc684fd43a70222696 100644 --- a/projet_personnel/algorithme_gestion_etudiants.py +++ b/projet_personnel/algorithme_gestion_etudiants.py @@ -32,7 +32,7 @@ name_pattern = re.compile(r'^[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}$') +telephone_pattern = re.compile(r'^\d{4}/\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])$') @@ -84,20 +84,17 @@ def register_student(data): print("The address is not valid. Make sure to follow the format 'street number, city'.") while True: - Telephone = input("What is the telephone number? (in the format 000/00.00.00) ") + Telephone = input("What is the telephone number? (in the format 0000/00.00.00) ") if telephone_pattern.match(Telephone): print(f"The telephone number is valid : {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.") - while True: - Email = input("Enter the university email (@student.uclouvain.be): ") - if email_pattern.match(Email): - print(f"The email is valid : {Email}") - break # Exit the loop if the email is valid - else: - print("The email is not valid. Make sure to follow the requested format.") + print("The email address was completed automatically. If it is not suitable you can modify it later : ") + email_of_student = f"{Firstname}{'.'}{Lastname}{'@student.uclouvain.be'}" + Email = email_of_student.lower() + print(Email) while True: Gender = input("What is your gender? (For Male enter M, for Female enter F, and for another type enter O): ") @@ -164,8 +161,10 @@ def register_student(data): 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.") + + matricule = generate_matricule(Firstname, Lastname, Date_of_birth) - register(data, Firstname, Lastname, Curriculum, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus) + register(data, Firstname, Lastname, Curriculum, Date_of_birth, Place_of_birth, Address, Telephone, Email, Gender, Academic_year, Courses_and_grade, Campus, matricule) # Display the entered information print("\nEntered Information:") @@ -181,6 +180,7 @@ def register_student(data): print(f"Curriculum: {Curriculum}") print(f"Courses and Grades: {Courses_and_grade}") print(f"Campus: {Campus}") + print(f"Matricule: {matricule}") while True: # Ask the user if they want to modify any information before registration @@ -195,14 +195,22 @@ def register_student(data): return +""" +def reload_data(file_path): + pd.read_excel(file_path) + return""" + +# faire la fonction qui permet de faire un reload des données !!!! -def register(data, firstname, lastname,Curriculum, date_of_birth, place_of_birth, address, telephone, email, gender, academic_year, courses_and_grade, campus): - matricule = generate_matricule(firstname, lastname, date_of_birth) + + + +def register(data, firstname, lastname, Curriculum, date_of_birth, place_of_birth, address, telephone, email, gender, academic_year, courses_and_grade, campus, matricule): student = { - "Name": firstname, - "Surname": lastname, + "Firstname": firstname, + "Lastname": lastname, "Curriculum":Curriculum, "Date of Birth": date_of_birth, "Place of Birth": place_of_birth, @@ -218,7 +226,9 @@ def register(data, firstname, lastname,Curriculum, date_of_birth, place_of_birth for course, grade in courses_and_grade.items(): student[course] = grade - data = pd.concat([data, student], ignore_index=True) + student_df = pd.DataFrame([student]) + data = pd.concat([data, student_df], ignore_index=True) + data.to_excel(file_path, index=False) print('The person has been registered.\n') @@ -442,8 +452,8 @@ def modify(data): # Mapping for field names to DataFrame column names field_mapping = { - 1: 'Name', - 2: 'Surname', + 1: 'Firstname', + 2: 'Lastname', 3: 'Date of Birth', 4: 'Place of Birth', 5: 'Address', diff --git a/projet_personnel/algorithme_student_generate.py b/projet_personnel/algorithme_student_generate.py index 9e24be519bbf3e62816697c233564c31e6c2a676..d20cc8a1e802c647e8a537716c44ee1b6cead33c 100644 --- a/projet_personnel/algorithme_student_generate.py +++ b/projet_personnel/algorithme_student_generate.py @@ -114,16 +114,16 @@ for each in range(number_of_students): # générer des données # attribuer un numero de téléphone à la personne phone_number = [] - n = f"{random.randint(10000000, 99999999):08d}" + n = f"{random.randint(100000000, 999999999):08d}" if n not in phone_number : phone_number.append(n) - phone = f"0{n[:2]}/{n[2:4]}.{n[4:6]}.{n[6:]}" + phone = f"0{n[:3]}/{n[3:5]}.{n[5:7]}.{n[7:]}" # endroit où habite la personne 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}" + adress_of_student = f"{student_street} {student_number_of_house}, {student_city}" #attribution du sexe d'une personne gender_of_student = random.choice(gender) @@ -190,7 +190,7 @@ for each in range(number_of_students): # générer des données grades[courses] = random.randint(0, 20) - data_generated.append({"Firstname": last_name, "Lastname": first_name, "Academic Year" : academic_year, "Curriculum" : curriculum, "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}) + data_generated.append({"Firstname": last_name, "Lastname": first_name, "Academic Year" : academic_year, "Curriculum" : curriculum, "Place of Birth" : city_of_birth , "Telephone": phone, "Address": adress_of_student, "Gender" : 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