From c547a74bba943859fa549df1f8600bf895b0f167 Mon Sep 17 00:00:00 2001 From: bdaneels Date: Fri, 25 Jul 2025 11:14:58 +0200 Subject: [PATCH] Add new scripts for processing exam groups and updating schedules; refactor existing code --- eindwerken ba controle/main.py | 32 ++ .../eindwerken controle/main.py | 32 ++ examen grote lokalen/main.py | 5 +- link-weaver-dashboard-view | 1 + .../examenrooster pre-syllabus (2).xls | 231 +++++++++++++ random/archief/examenrooster pre-syllabus.xls | 324 ++++++++++++++++++ random/bascriptiegroepennaarexamengroepen.py | 31 ++ random/script 2.py | 2 +- random/script.py | 58 ++-- 9 files changed, 678 insertions(+), 38 deletions(-) create mode 100644 eindwerken ba controle/main.py create mode 100644 eindwerken ma controle/eindwerken controle/main.py create mode 160000 link-weaver-dashboard-view create mode 100644 random/archief/examenrooster pre-syllabus (2).xls create mode 100644 random/archief/examenrooster pre-syllabus.xls diff --git a/eindwerken ba controle/main.py b/eindwerken ba controle/main.py new file mode 100644 index 0000000..ea2fc78 --- /dev/null +++ b/eindwerken ba controle/main.py @@ -0,0 +1,32 @@ + +import pandas as pd + +promotor_assessor = { + "De Munck": ["De Groot"], + "Gelderblom": ["Van Laer"], + "Blondé": ["Schepers", "Kole"], + "Puttevils": ["Heijmans"], + "Greefs": ["Tanis"], + "Wynants": ["Samoy", "Welslau"] +} + +df = pd.read_excel('sisa.xlsx', sheet_name='sheet1') + +for idx, row in df.iterrows(): + promotor_cell = str(row.get('Promotor', '')).strip() + assessors_cell = [a.strip() for a in str(row.get('Assessor(en)', '')).split(',')] + matched_promotor = None + for key in promotor_assessor: + if key in promotor_cell or promotor_cell in key: + matched_promotor = key + break + if matched_promotor: + expected = promotor_assessor[matched_promotor] + missing = [] + for e in expected: + if not any(e in a or a in e for a in assessors_cell): + missing.append(e) + if missing: + print(f"Row {idx+1}: ERROR: Expected assessors {expected}, found {assessors_cell}") + +print("Check completed successfully.") \ No newline at end of file diff --git a/eindwerken ma controle/eindwerken controle/main.py b/eindwerken ma controle/eindwerken controle/main.py new file mode 100644 index 0000000..a98701a --- /dev/null +++ b/eindwerken ma controle/eindwerken controle/main.py @@ -0,0 +1,32 @@ +import pandas as pd +import openpyxl + + + + +sisa_file = pd.read_excel("sisa file.xlsx", sheet_name="Sheet1") +reinoud_file = pd.read_excel("reinoud file.xlsx", sheet_name="Sheet1") + + +sisa_file["Promotor"] = sisa_file["Promotor"].str.rsplit(" ", n=1).str[0] + +sisa_file["Full Name"] = sisa_file["Achternaam"] + " " + sisa_file["Voornaam"] + +# Step 3: Check if the Full Name exists in the Naam column of the reinoud file +merged = sisa_file.merge(reinoud_file, left_on="Full Name", right_on="Naam", how="inner") + +# Step 4: Find divergent Promotor values +divergent_promotors = merged[merged["Promotor_x"] != merged["Promotor_y"]] + +# Step 5: Check if Assessor(en) contains Lector 1 and Lector 2 +def check_assessors(row): + assessors = row["Assessor(en)"] + return all(lector in assessors for lector in [row["Lector 1"], row["Lector 2"]]) + +merged["Assessors Match"] = merged.apply(check_assessors, axis=1) + +# Save results +divergent_promotors.to_excel("divergent_promotors.xlsx", index=False) +merged.to_excel("merged_results.xlsx", index=False) + +print("Processing complete. Results saved.") \ No newline at end of file diff --git a/examen grote lokalen/main.py b/examen grote lokalen/main.py index a3ff496..e829334 100644 --- a/examen grote lokalen/main.py +++ b/examen grote lokalen/main.py @@ -2,7 +2,7 @@ import pandas as pd # Constants FILE_PATH = 'file.xlsx' -SHEET_NAME = 'ps (32)' +SHEET_NAME = 'ps (53)' OUTPUT_FILE_PATH = 'filtered_grote_lokalen.xlsx' EXAM_FORM_COLUMN = 'Examenvorm' REGISTRATION_COLUMN = 'Aant. inschr.' @@ -10,6 +10,7 @@ BEGIN_TIME_COLUMN = 'Beginuur S+' END_TIME_COLUMN = 'Einduur S+' TEACHERS_COLUMN = 'Docenten' LOCATION_COLUMNS = ['Datum S+', BEGIN_TIME_COLUMN, END_TIME_COLUMN, 'Studiegidsnr.', 'Omschrijving', TEACHERS_COLUMN, REGISTRATION_COLUMN] +AANTAL_STUDENTEN = 65 # Read the Excel file def read_excel(file_path, sheet_name): @@ -18,7 +19,7 @@ def read_excel(file_path, sheet_name): # Filter DataFrame def filter_dataframe(df): df = df[df[EXAM_FORM_COLUMN] == 'Schriftelijk'] - df = df[df[REGISTRATION_COLUMN] > 65] + df = df[df[REGISTRATION_COLUMN] > AANTAL_STUDENTEN] return df[LOCATION_COLUMNS] # Format time strings diff --git a/link-weaver-dashboard-view b/link-weaver-dashboard-view new file mode 160000 index 0000000..846d0f6 --- /dev/null +++ b/link-weaver-dashboard-view @@ -0,0 +1 @@ +Subproject commit 846d0f6fb41ee880bef7acae427f744c2fffc8df diff --git a/random/archief/examenrooster pre-syllabus (2).xls b/random/archief/examenrooster pre-syllabus (2).xls new file mode 100644 index 0000000..9694617 --- /dev/null +++ b/random/archief/examenrooster pre-syllabus (2).xls @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Studiegidsnr.OmschrijvingDocentenSPAant. inschr.ExamenvormTijdslots aanvr.SSSExamen groepAant. stdnt. gr.Datum S+Beginuur S+Einduur S+Facilitieit S+Code examenroosterExtra info voor studenten
2002FLWGESHistorisch atelierTitularis Beyen,Marnix6,002MondelingN1222/08/202509:0013:002002FLWGES7852_224003_M1_1
2004FLWGESTheorie van de hist. kennisTitularis De Munck,Bert6,008MondelingN1825/08/202508:3012:302004FLWGES8023_224003_M1_1
2013FLWGESLandschapsgeschiedenisTitularis Soens,Tim - Titularis Jongepier,Iason6,002MondelingN1221/08/202514:0017:002013FLWGES1238_224003_M1_1
2064FLWGESPolitieke Geschiedenis: themaTitularis de Smaele,Henk6,003MondelingN132064FLWGES16077_224003_M1_1niet roosteren, studenten vragen docenten te contacteren
2041FLWGESTheorie en gesch stedenbouwTitularis De Block,Greet6,002MondelingN1201/09/202509:3012:002041FLWGES15506_224003_M1_1
2066FLWGESWar and Occupation Middle EastCo-Titularis Sayim,Burak
Titularis Shaery-Yazdi,Roschanack
Titularis Beyen,Marnix
6,00MondelingN12066FLWGES16110_224003_M1_2
2046FLWGESStage Cultureel ErfgoedTitularis Delsaerdt,Pierre6,00MondelingN12046FLWGES15618_224003_M1_1
2053FLWGESUrban History and TheoryTitularis Van Damme,Ilja6,001MondelingN1102/09/202509:0012:302053FLWGES15754_224003_M1_1
2063FLWGESCultureel erfgoedTitularis Shaery-Yazdi,Roschanack - Titularis De Roo,Bas6,001MondelingN1104/09/202510:0012:302063FLWGES16071_224003_M1_1
2066FLWGESWar and Occupation Middle EastCo-Titularis Sayim,Burak
Titularis Shaery-Yazdi,Roschanack
Titularis Beyen,Marnix
6,00PC examenN12066FLWGES16110_224003_D1_1
2065FLWGESCultureel erfgoedTitularis Delsaerdt,Pierre6,00SchriftelijkN12065FLWGES16091_224003_S1_1
2045FLWGESMasterproefCo-Titularis Vermoesen,Reinoud - Titularis NNB,- - Medewerker NNB,18,0018SchriftelijkN11818/08/202509:0016:002045FLWGES15597_224003_S1_1
2023FLWGESHist Body, Gender, SexualityTitularis de Smaele,Henk6,003SchriftelijkN1328/08/202513:3016:302023FLWGES15226_224003_S1_1
2073FLWGESJoodse Geschiedenis NTTitularis Dunkelgrün,Theodor6,001SchriftelijkN1126/08/202508:0012:002073FLWGES16177_224003_S1_1
\ No newline at end of file diff --git a/random/archief/examenrooster pre-syllabus.xls b/random/archief/examenrooster pre-syllabus.xls new file mode 100644 index 0000000..812dc33 --- /dev/null +++ b/random/archief/examenrooster pre-syllabus.xls @@ -0,0 +1,324 @@ + + + + + + + + + + + + + + + + + + + + + + <body> + <p>This page uses frames, but your browser doesn't support them.</p> + </body> + + + diff --git a/random/bascriptiegroepennaarexamengroepen.py b/random/bascriptiegroepennaarexamengroepen.py index e69de29..dc9a8df 100644 --- a/random/bascriptiegroepennaarexamengroepen.py +++ b/random/bascriptiegroepennaarexamengroepen.py @@ -0,0 +1,31 @@ +import pandas as pd + + +def assign_exam_group(value): + mapping = { + "Hoofd versus hand: de waardering van ambacht en ambachtelijkheid herbekeken, 1500-2024": 6, + "De wereld van een koopman in de briefwisseling van Henri-François Schilders, tweede helft zeventiende eeuw": 1, + "Hoe overleef ik een revolutie? Huishoudens en hun overlevingsstrategieën in een tijd van polarisatie en verandering (1750-1850)": 5, + "Komt dat zien! Het theatrale uitgaansleven in België in de negentiende en vroege twintigste eeuw (1830-1930)": 4 , + "Erfenisaangiften als venster op de Antwerpse samenleving, 1835 – 1912": 3, + "Sporen van gulden en franken. De geldzaken van huishoudens in de twintigste eeuw": 2, + # Add more mappings as needed + } + return mapping.get(value, 0) # Default to 0 if no match + + +def process_excel(file_path): + df = pd.read_excel(file_path, sheet_name="Sheet1") + + if 'Groep' not in df.columns: + raise ValueError("Column 'Groep' not found in the Excel file.") + + df['Examengroep'] = df['Groep'].apply(assign_exam_group) + + output_file = "processed_" + file_path + df.to_excel(output_file, index=False) + print(f"Processed file saved as {output_file}") + + +if __name__ == "__main__": + process_excel("bascriptie groepen.xlsx") diff --git a/random/script 2.py b/random/script 2.py index ea1718b..0a86817 100644 --- a/random/script 2.py +++ b/random/script 2.py @@ -128,4 +128,4 @@ def compare_roosters(base_file, comparison_file, output_file): # Example usage: -compare_roosters('afgewerkte.xlsx', 'bages rooster voor s.xlsx', 'differences_output.xlsx') +compare_roosters('examenrooster post-syllabus.xlsx', 'examenrooster pre-syllabus.xlsx', 'differences_output.xlsx') diff --git a/random/script.py b/random/script.py index f728f73..ae529f7 100644 --- a/random/script.py +++ b/random/script.py @@ -2,65 +2,53 @@ import pandas as pd from datetime import datetime import locale -file_path = 'bages rooster voor s.xlsx' +file_path = 'examenrooster pre-syllabus.xlsx' sheet_name = 'rooster' df = pd.read_excel(file_path, sheet_name=sheet_name) date_ranges = { - (pd.Timestamp('2025-01-06'), pd.Timestamp('2025-01-12')): 16, - (pd.Timestamp('2025-01-13'), pd.Timestamp('2025-01-19')): 17, - (pd.Timestamp('2025-01-20'), pd.Timestamp('2025-01-26')): 18, - (pd.Timestamp('2025-01-27'), pd.Timestamp('2025-02-02')): 19, - - # add more ranges as needed + (pd.Timestamp('2025-05-26'), pd.Timestamp('2025-06-01')): 36, + (pd.Timestamp('2025-06-02'), pd.Timestamp('2025-06-08')): 37, + (pd.Timestamp('2025-06-09'), pd.Timestamp('2025-06-15')): 38, + (pd.Timestamp('2025-06-16'), pd.Timestamp('2025-06-22')): 39, + (pd.Timestamp('2025-08-18'), pd.Timestamp('2025-08-24')): 48, + (pd.Timestamp('2025-08-25'), pd.Timestamp('2025-08-31')): 49, + (pd.Timestamp('2025-09-01'), pd.Timestamp('2025-09-06')): 50, } - -# Custom date parser function def parse_custom_date(date_str): if pd.isna(date_str): - return pd.NaT # Return pandas NaT for missing dates + return pd.NaT + if isinstance(date_str, pd.Timestamp): + return date_str if isinstance(date_str, str): try: - # Set locale to Dutch locale.setlocale(locale.LC_TIME, 'nl_NL.UTF-8') return datetime.strptime(date_str, '%A %d %B %Y') except ValueError as e: raise ValueError(f"Date conversion error: {e} for date string: {date_str}") finally: - # Reset locale to the default setting locale.setlocale(locale.LC_TIME, 'C') else: - raise TypeError(f"Expected string, got {type(date_str).__name__}: {date_str}") + raise TypeError(f"Expected string or Timestamp, got {type(date_str).__name__}: {date_str}") +def update_lesweek(date): + if pd.isna(date): + return 0 + for date_range, lesweek_value in date_ranges.items(): + if date_range[0] <= date <= date_range[1]: + return lesweek_value + return 0 -# Ensure the column 'Datum S+' exists and is processed correctly -if 'Datum S+' in df.columns: +if 'Datum' in df.columns: try: - # Convert 'Datum S+' column to datetime using the custom parser - df['Datum S+'] = df['Datum S+'].apply(parse_custom_date) + df['Datum'] = df['Datum'].apply(parse_custom_date) + print(df['Datum'].apply(type).value_counts()) # Debug: print types after parsing except (ValueError, TypeError) as e: print(f"Error: {e}") - # Optionally, re-raise the exception if you want to stop execution raise + df['Lesweek'] = df['Datum'].apply(update_lesweek) - - # Function to update Lesweek based on date ranges - def update_lesweek(date): - if pd.isna(date): # Handle NaT values - return 0 - for date_range, lesweek_value in date_ranges.items(): - if date_range[0] <= date <= date_range[1]: - return lesweek_value - return 0 # Default value if date doesn't fall in any range - - - # Apply the function to 'Datum S+' column - df['Lesweek'] = df['Datum S+'].apply(update_lesweek) - -# Check the results print("\nFirst few rows of the DataFrame to verify date formatting:\n", df.head()) - -# If needed, you can save the DataFrame to a new Excel file to verify changes df.to_excel('updated_rooster.xlsx', index=False) \ No newline at end of file