klassen in File speichern

Übersicht in Excel
This commit is contained in:
Patrick vom Hagen
2024-08-02 15:08:04 +02:00
parent 936a00c81f
commit 3e36a1513e
3 changed files with 22 additions and 42 deletions

View File

@@ -1,8 +1,9 @@
import numpy as np
import pandas as pd
from Levenshtein import distance
def compare_data(new, sys, count_test):
def compare_data(new, sys, count_test, path):
print(f"\nEinträge in System Liste: {len(sys)}")
print(f"Einträge in Import Liste: {len(new)}")
@@ -25,7 +26,7 @@ def compare_data(new, sys, count_test):
only_new = merged_df[merged_df['_merge'] == 'left_only'].drop(columns=['_merge'])
only_sys = merged_df[merged_df['_merge'] == 'right_only'].drop(columns=['_merge'])
print_status(matches, only_new, only_sys, count_test)
print_status(matches, only_new, only_sys, count_test, path)
search_typos(only_new[['name', 'vorname']], only_sys[['name', 'vorname']])
return matches, only_new
@@ -50,10 +51,17 @@ def unique_classes(df):
df['klasse'] = df['klasse'].str.split(',')
df = df.explode('klasse')
eindeutige_klassen = df['klasse'].unique()
print(eindeutige_klassen)
with open('./output/klassen.txt', 'a') as file:
file.write(np.array_str(eindeutige_klassen))
# print(eindeutige_klassen)
def print_status(matches, new, old, count_test):
def print_status(matches, new, old, count_test, path):
print("\nAnzahl neuer Nutzer:", len(new))
print("Anzahl Übereinstimmungen:", len(matches) + count_test)
print("Anzahl veralteter Nutzer:", len(old) - count_test)
with pd.ExcelWriter(path, engine='openpyxl') as writer:
matches.to_excel(writer, sheet_name='Matches', index=False)
new.to_excel(writer, sheet_name='Neu', index=False)
old.to_excel(writer, sheet_name='Alt', index=False)