diff --git a/main.py b/main.py index b0646747929b0e9f08d5c4cb8a4ff7c880912a74..83e3ded6210200cb511c01f67915a12db2102f78 100644 --- a/main.py +++ b/main.py @@ -1,30 +1,61 @@ import pandas as pd import os +import openpyxl from itertools import combinations -file_groupes_sillons = 'groupes_sillons/VET_JC_CLEAN.xlsx' +file_groupes_sillons = 'groupes_sillons/VET_Info.xlsx' directory_incomp_path = 'incomp_apogee' files_incomp_apogee = [os.path.join(directory_incomp_path, file) for file in os.listdir(directory_incomp_path) if file.endswith('.xlsx')] -df = pd.read_excel(file_groupes_sillons) +wb = openpyxl.load_workbook(file_groupes_sillons) +ws = wb.active sillon_to_groups = {} +groupe_to_sillons = {} +groupe_to_ue = {} all_incompatibilities_apogee = set() all_incompatibilities_theory = set() # fonction pour charger les correspondances groupes/sillons def dic_creator(): - for index, row in df.iterrows(): - group_name = row['Nom'].strip().upper() - sillons = row['Sillon'] - sillons_list = str(sillons).split('+') + current_sillon = None + current_ue = None + for row in ws.iter_rows(min_row=2, min_col=3, max_col=5, values_only=True): + ue, group_name, sillon = row + group_name = group_name.strip().upper() + + # si la cellule sillon est vide (cas fusion), on utilisera la dernière valeur connue + if sillon: + current_sillon = sillon + # si la cellule ue est vide (cas fusion), on utilisera la dernière valeur connue + if ue: + current_ue = ue + sillons_list = str(current_sillon).split('+') + for sillon in sillons_list: - sillon = sillon.strip() - if sillon and any(sillon == f"{i}{letter}" for i in range(1, 9) for letter in ['', 'A', 'B']): + sillon = sillon.strip().upper() + if sillon and any(sillon == f"{i}{letter}" for i in range(1, 9) for letter in ['', 'A', 'B', 'a', 'b']): if sillon in sillon_to_groups: sillon_to_groups[sillon].append(group_name) else: sillon_to_groups[sillon] = [group_name] + else: + print(f"Sillon pas reconnu: {row}") + groupe_to_sillons[group_name] = [s.strip().upper() for s in sillons_list] + groupe_to_ue[group_name] = current_ue + + +def afficher_infos(): + print("Sillons to Groupes:") + for sillon, groupes in sillon_to_groups.items(): + print(f"Sillon {sillon}: {groupes}") + print("\nGroupes to Sillons:") + for groupe, sillons in groupe_to_sillons.items(): + print(f"Groupe {groupe}: {sillons}") + print("\nGroupes to Cours:") + for groupe, cours in groupe_to_ue.items(): + print(f"Groupe {groupe}: {cours}") + # fonction pour vérifier si deux groupes donnés sont incompatibles (même sillon # en tenant compte des demi-sillons) @@ -87,8 +118,9 @@ def verifier_theory_vs_apogee(): print("Aucun oubli détecté.") dic_creator() -print("--- Apogee vs. theory ---") -verifier_apogee_vs_theory() -incomp_theory_creator() -print("--- Theory vs. apogee ---") -verifier_theory_vs_apogee() +afficher_infos() +# print("--- Apogee vs. theory ---") +# verifier_apogee_vs_theory() +# incomp_theory_creator() +# print("--- Theory vs. apogee ---") +# verifier_theory_vs_apogee()