step3.py updated
This commit is contained in:
21
main.py
21
main.py
@@ -41,10 +41,10 @@ if __name__ == "__main__":
|
|||||||
log_file_path = 'log.txt'
|
log_file_path = 'log.txt'
|
||||||
if os.path.exists(log_file_path):
|
if os.path.exists(log_file_path):
|
||||||
open(log_file_path, 'w').close()
|
open(log_file_path, 'w').close()
|
||||||
# sys.stdout = Logger.Logger(log_file_path)
|
sys.stdout = Logger.Logger(log_file_path)
|
||||||
|
|
||||||
print("Schul-IT UCS-Import Tool:\n")
|
print("Schul-IT UCS-Import Tool:\n")
|
||||||
dev = True
|
dev = True # CHANGE FOR PRODUCTION RUN <------
|
||||||
|
|
||||||
# ----------------------------------------------------------------- #
|
# ----------------------------------------------------------------- #
|
||||||
# Step 1 - Dateien wählen, formatieren, einlesen | Variablen setzen #
|
# Step 1 - Dateien wählen, formatieren, einlesen | Variablen setzen #
|
||||||
@@ -70,11 +70,11 @@ if __name__ == "__main__":
|
|||||||
print("Schul ID:", school_id, "\nOX-Context:", ox_context, "\nNullen:", del_zeros)
|
print("Schul ID:", school_id, "\nOX-Context:", ox_context, "\nNullen:", del_zeros)
|
||||||
|
|
||||||
lul_new = step1.check_export_file(lehrer_liste_neu)
|
lul_new = step1.check_export_file(lehrer_liste_neu)
|
||||||
# print("Spalten der Import Liste - Lehrer:", lul_new.columns)
|
# print("Spalten der Import Liste - Lehrer: ", lul_new.columns)
|
||||||
lul_sys = step1.create_dataframe_system(lehrer_liste_system)
|
lul_sys = step1.create_dataframe_system(lehrer_liste_system)
|
||||||
|
|
||||||
sus_new = step1.check_export_file(schueler_liste_neu)
|
sus_new = step1.check_export_file(schueler_liste_neu)
|
||||||
# print("Spalten der Import Liste - Schüler:", sus_new.columns)
|
# print("Spalten der Import Liste - Schüler: ", sus_new.columns)
|
||||||
sus_sys = step1.create_dataframe_system(schueler_liste_system)
|
sus_sys = step1.create_dataframe_system(schueler_liste_system)
|
||||||
|
|
||||||
# Test- und Funktionsuser auslagern
|
# Test- und Funktionsuser auslagern
|
||||||
@@ -92,16 +92,19 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# 2.1 Data Frames für Abgleich erstellen
|
# 2.1 Data Frames für Abgleich erstellen
|
||||||
print(" Lehrer:innen:")
|
print(" Lehrer:innen:")
|
||||||
lul_matched, new_lul = step2.compare_data(lul_new, lul_sys, False)
|
lul_matched, new_lul = step2.compare_data(lul_new, lul_sys)
|
||||||
print("\n Schüler:innen:")
|
print("\n Schüler:innen:")
|
||||||
sus_matched, new_sus = step2.compare_data(sus_new, sus_sys, True)
|
sus_matched, new_sus = step2.compare_data(sus_new, sus_sys,)
|
||||||
|
print("Step2 completed! \n")
|
||||||
|
|
||||||
|
sys.stdout = sys.__stdout__
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------#
|
# ----------------------------------------------------------------------------------------#
|
||||||
# Step 3 - Import Data generieren - klasse, uuids, weiteres in einer Liste zusammenführen #
|
# Step 3 - Import Data generieren - klasse, uuids, weiteres in einer Liste zusammenführen #
|
||||||
|
|
||||||
# Lul: Namen + UUIDs + Testuser
|
# Lul: Namen + UUIDs + Testuser
|
||||||
lul_import = step3.add_school_data(lul_sys, school_id, ox_context, mail_quota_lul, ox_quota_lul)
|
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)
|
||||||
|
print(lul_import[['name', 'klasse', 'schuelerid']])
|
||||||
# SuS: Namen + UUIDs + Klassen + Testuser
|
# SuS: Namen + UUIDs + Klassen + Testuser
|
||||||
# sus_import = step3.add_school_data(sus_sys, school_id, ox_context, mail_quota_sus, ox_quota_sus)
|
# sus_import = step3.add_school_data(sus_sys, school_id, ox_context, mail_quota_sus, ox_quota_sus)
|
||||||
|
|
||||||
sys.stdout = sys.__stdout__
|
|
||||||
|
|||||||
11
src/step2.py
11
src/step2.py
@@ -2,10 +2,12 @@ import pandas as pd
|
|||||||
from Levenshtein import distance
|
from Levenshtein import distance
|
||||||
|
|
||||||
|
|
||||||
def compare_data(new, sys, bool_class):
|
def compare_data(new, sys):
|
||||||
print(f"\nEinträge in Import Liste: {len(new)}")
|
print(f"\nEinträge in Import Liste: {len(new)}")
|
||||||
print(f"Einträge in System Liste: {len(sys)}")
|
print(f"Einträge in System Liste: {len(sys)}")
|
||||||
|
|
||||||
|
bool_class = 'klasse' in new.columns
|
||||||
|
|
||||||
if bool_class:
|
if bool_class:
|
||||||
if 'index' in new.columns:
|
if 'index' in new.columns:
|
||||||
new = new.drop('index', axis=1)
|
new = new.drop('index', axis=1)
|
||||||
@@ -35,9 +37,10 @@ def search_typos(new, sys):
|
|||||||
for idx1, row1 in new.iterrows():
|
for idx1, row1 in new.iterrows():
|
||||||
for idx2, row2 in sys.iterrows():
|
for idx2, row2 in sys.iterrows():
|
||||||
if distance(row1[col1], row2[col1]) <= 2 and distance(row1[col2], row2[col2]) <= 2:
|
if distance(row1[col1], row2[col1]) <= 2 and distance(row1[col2], row2[col2]) <= 2:
|
||||||
typos.append((row1[col1], row1[col2], row2[col1], row2[col2]))
|
typos.append(([row1[col1], row1[col2]], [row2[col1], row2[col2]]))
|
||||||
if len(typos) > 0:
|
typo_df = pd.DataFrame(typos, columns=['Import', 'System'])
|
||||||
print('Mögliche Tippfehler:', len(typos), '\n', typos)
|
if len(typo_df) > 0:
|
||||||
|
print('Mögliche Tippfehler:', len(typo_df), '\n', typo_df)
|
||||||
else:
|
else:
|
||||||
print('Mögliche Tippfehler: keine Fehler gefunden!')
|
print('Mögliche Tippfehler: keine Fehler gefunden!')
|
||||||
|
|
||||||
|
|||||||
14
src/step3.py
14
src/step3.py
@@ -1,15 +1,25 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
def create_uuid():
|
def create_uuid():
|
||||||
return str(uuid.uuid4())
|
return str(uuid.uuid4())
|
||||||
|
|
||||||
|
|
||||||
def merch_uuids(new, sys):
|
def merch_uuids(new, sys, dev):
|
||||||
return 0
|
print(sys[['name', 'klasse', 'schuelerid']])
|
||||||
|
print(new[['name', 'klasse', 'schuelerid']])
|
||||||
|
if dev:
|
||||||
|
new_uuids = ["test" for _ in range(len(new))]
|
||||||
|
else:
|
||||||
|
new_uuids = [create_uuid() for _ in range(len(new))]
|
||||||
|
new['schuelerid'] = new_uuids
|
||||||
|
|
||||||
|
return pd.concat([sys, new], ignore_index=True)
|
||||||
|
|
||||||
|
|
||||||
def add_school_data(df, school_id, ox_context, mail_quota, ox_quota):
|
def add_school_data(df, school_id, ox_context, mail_quota, ox_quota):
|
||||||
|
# print(df.head())
|
||||||
df['mailUserQuota'] = mail_quota
|
df['mailUserQuota'] = mail_quota
|
||||||
df['oxUserQuota'] = ox_quota
|
df['oxUserQuota'] = ox_quota
|
||||||
df['oxContext'] = ox_context
|
df['oxContext'] = ox_context
|
||||||
|
|||||||
Reference in New Issue
Block a user