log Einträge gekürzt
This commit is contained in:
26
main.py
26
main.py
@@ -38,7 +38,7 @@ ox_quota_sus = 5120 # oxUserQuota LuL
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Erstellt oder löscht Inhalte vorhandener Logdatei und loggt Konsolenausgaben
|
||||
log_file_path = 'log.txt'
|
||||
log_file_path = 'output/log.txt'
|
||||
if os.path.exists(log_file_path):
|
||||
open(log_file_path, 'w').close()
|
||||
sys.stdout = Logger.Logger(log_file_path)
|
||||
@@ -48,17 +48,16 @@ if __name__ == "__main__":
|
||||
|
||||
# ----------------------------------------------------------------- #
|
||||
# Step 1 - Dateien wählen, formatieren, einlesen | Variablen setzen #
|
||||
print("Step1: Listen einlesen\n")
|
||||
|
||||
# ToDo Daten mit UI einlesen
|
||||
# lehrer_liste_neu = "./Data/SaM/export_lehrer_SaM.csv"
|
||||
lehrer_liste_neu = "./Data/GKS/exportLuL.csv"
|
||||
lehrer_liste_system = "./Data//GKS/systemLuL.csv"
|
||||
lul_out_path = './Data/outputLehrer.csv'
|
||||
lul_out_path = 'output/outputLehrer.csv'
|
||||
|
||||
schueler_liste_neu = "./Data/GKS/exportSuS.csv"
|
||||
schueler_liste_system = "./Data/GKS/systemSuS.csv"
|
||||
sus_out_path = './Data/outputSchueler.csv'
|
||||
sus_out_path = 'output/outputSchueler.csv'
|
||||
|
||||
# Variablen füllen:
|
||||
if not dev:
|
||||
@@ -87,33 +86,22 @@ if __name__ == "__main__":
|
||||
|
||||
# ---------------------------------------------------- #
|
||||
# Step 2 - auf name, vorname reduzieren und abgleichen #
|
||||
print("\nStep2: Listen abgleichen")
|
||||
|
||||
print("\n Lehrer:innen:")
|
||||
lul_matched, new_lul = step2.compare_data(lul_new, lul_sys)
|
||||
print("\n Schüler:innen:")
|
||||
sus_matched, new_sus = step2.compare_data(sus_new, sus_sys,)
|
||||
print("\nStep2: Abgleich abgeschlossen! \n")
|
||||
|
||||
# ----------------------------------------------------------------------------------------#
|
||||
# Step 3 - Import Data generieren - klasse, uuids, weiteres in einer Liste zusammenführen #
|
||||
|
||||
# Lul: Namen + UUIDs + Testuser
|
||||
lul_import = step3.merch_uuids(new_lul, lul_matched, dev)
|
||||
lul_import = step3.add_school_data(lul_import, school_id, ox_context, mail_quota_lul, ox_quota_lul)
|
||||
lul_import = pd.concat([lul_import, lul_testuser_df], ignore_index=True)
|
||||
print(f"{len(lul_testuser_df)} Testuser angefügt - {len(lul_import)} Einträge in LuL Liste")
|
||||
lul_import.to_csv(lul_out_path, sep=';', index=False)
|
||||
print(f"LuL Import CSV unter {lul_out_path} erfolgreich erstellt!")
|
||||
step3.create_output_list('LuL', new_lul, lul_matched, dev, school_id, ox_context,
|
||||
mail_quota_lul, ox_quota_lul, lul_testuser_df, lul_out_path)
|
||||
|
||||
# SuS: Namen + UUIDs + Klassen + Testuser
|
||||
sus_import = step3.merch_uuids(new_sus, sus_matched, dev)
|
||||
sus_import = step3.add_school_data(sus_import, school_id, ox_context, mail_quota_sus, ox_quota_sus)
|
||||
sus_import = pd.concat([sus_import, sus_testuser_df], ignore_index=True)
|
||||
print(f"{len(sus_testuser_df)} Testuser angefügt - {len(sus_import)} Einträge in SuS Liste")
|
||||
sus_import.to_csv(sus_out_path, sep=';', index=False)
|
||||
print(f"SuS Import CSV unter {sus_out_path} erfolgreich erstellt!")
|
||||
print("\nImport Script beendet.")
|
||||
step3.create_output_list('SuS', new_sus, sus_matched, dev, school_id, ox_context,
|
||||
mail_quota_sus, ox_quota_sus, sus_testuser_df, sus_out_path)
|
||||
|
||||
# Log Datei fertig - Ausgang schließen
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
17
src/step3.py
17
src/step3.py
@@ -6,10 +6,10 @@ def create_uuid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
def add_hl_tag(school_id, row):
|
||||
def add_hl_tag(sid, row):
|
||||
klasse = str(row['klasse'])
|
||||
if klasse != 'nan':
|
||||
return school_id + '-' + klasse
|
||||
return sid + '-' + klasse
|
||||
|
||||
|
||||
def merch_uuids(new, sys, dev):
|
||||
@@ -22,9 +22,18 @@ def merch_uuids(new, sys, dev):
|
||||
return pd.concat([sys, new], ignore_index=True)
|
||||
|
||||
|
||||
def add_school_data(df, school_id, ox_context, mail_quota, ox_quota):
|
||||
df['klasse'] = df.apply(lambda row: add_hl_tag(school_id, row), axis=1)
|
||||
def add_school_data(df, sid, ox_context, mail_quota, ox_quota):
|
||||
df['klasse'] = df.apply(lambda row: add_hl_tag(sid, row), axis=1)
|
||||
df['mailUserQuota'] = mail_quota
|
||||
df['oxUserQuota'] = ox_quota
|
||||
df['oxContext'] = ox_context
|
||||
return df
|
||||
|
||||
|
||||
def create_output_list(name, new, matched, dev, sid, oxc, mail_q, oxq, testuser, out_path):
|
||||
df = merch_uuids(new, matched, dev)
|
||||
df = add_school_data(df, sid, oxc, mail_q, oxq)
|
||||
df = pd.concat([df, testuser], ignore_index=True)
|
||||
print(f"\n{len(testuser)} Testuser angefügt - {len(df)} Einträge in {name} Liste")
|
||||
df.to_csv(out_path, sep=';', index=False)
|
||||
print(f"{name} Import CSV unter {out_path} erfolgreich erstellt!")
|
||||
|
||||
Reference in New Issue
Block a user