step1.py udated
This commit is contained in:
16
GUI/import_gui.py
Normal file
16
GUI/import_gui.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from kivy.app import App
|
||||||
|
from kivy.uix.gridlayout import GridLayout
|
||||||
|
from kivy.uix.image import Image
|
||||||
|
|
||||||
|
|
||||||
|
class ImportGUI(App):
|
||||||
|
def build(self):
|
||||||
|
self.window = GridLayout()
|
||||||
|
self.window.cols = 3
|
||||||
|
self.window.add_widget(Image(source="add.png"))
|
||||||
|
|
||||||
|
return self.window
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ImportGUI().run()
|
||||||
@@ -1 +1,7 @@
|
|||||||
# UCS Import mit Python Script
|
# UCS Import mit Python Script
|
||||||
|
|
||||||
|
© Patrick vom Hagen - 2024
|
||||||
|
|
||||||
|
## Konzept
|
||||||
|
|
||||||
|
Mit diesem Tool soll ein Listenabgleich zwischen einer neuen Liste einer
|
||||||
@@ -8,18 +8,18 @@ def check_file(path):
|
|||||||
result = chardet.detect(file.read())
|
result = chardet.detect(file.read())
|
||||||
|
|
||||||
detected_encoding = result['encoding']
|
detected_encoding = result['encoding']
|
||||||
try:
|
# try:
|
||||||
pd.read_csv(path, encoding=detected_encoding)
|
# pd.read_csv(path, encoding=detected_encoding)
|
||||||
except pd.errors.ParserError as e:
|
# except pd.errors.ParserError as e:
|
||||||
# Wenn ein Parserfehler auftritt, gibt eine Fehlermeldung aus
|
# # Wenn ein Parserfehler auftritt, gibt eine Fehlermeldung aus
|
||||||
print(f"Fehler beim Einlesen der CSV-Datei: {e}")
|
# print(f"Fehler beim Einlesen der CSV-Datei: {e}")
|
||||||
print()
|
# print()
|
||||||
data = open(path, "r")
|
# data = open(path, "r")
|
||||||
data = ''.join([i for i in data]).replace(",", "")
|
# data = ''.join([i for i in data]).replace(",", "")
|
||||||
x = open(path, "w")
|
# x = open(path, "w")
|
||||||
x.writelines(data)
|
# x.writelines(data)
|
||||||
x.close()
|
# x.close()
|
||||||
print(f"Alle Kommas entfernt")
|
# print(f"Alle Kommas entfernt")
|
||||||
|
|
||||||
|
|
||||||
# Prüft Formatierung der CSV, formatiert diese zu utf-8 und speichert das Ergebnis als neue Liste
|
# Prüft Formatierung der CSV, formatiert diese zu utf-8 und speichert das Ergebnis als neue Liste
|
||||||
@@ -30,6 +30,7 @@ def format_csv(path, type):
|
|||||||
detected_encoding = result['encoding']
|
detected_encoding = result['encoding']
|
||||||
|
|
||||||
# CSV-Datei mit Pandas einlesen
|
# CSV-Datei mit Pandas einlesen
|
||||||
|
# in step1 nicht notwendig, da nicht mit csv, sondern mit pandas frame gearbeitet wird
|
||||||
try:
|
try:
|
||||||
df = pd.read_csv(path, encoding=detected_encoding)
|
df = pd.read_csv(path, encoding=detected_encoding)
|
||||||
print("Datei erfolgreich eingelesen.")
|
print("Datei erfolgreich eingelesen.")
|
||||||
|
|||||||
29
main.py
29
main.py
@@ -7,24 +7,25 @@
|
|||||||
###############################################################
|
###############################################################
|
||||||
# IMPORT - standard Python imports für benötigte Bibliotheken #
|
# IMPORT - standard Python imports für benötigte Bibliotheken #
|
||||||
|
|
||||||
import pandas as pd # pandas für Datenmanagement
|
from src import step1
|
||||||
import chardet # chardet erkennt Formatierung - Umwandlung des erkannten Formats in UTF-8
|
import pandas as pd # pandas für Datenmanagement
|
||||||
import csv # zur Verarbeitung von .csv Dateien
|
import chardet # chardet erkennt Formatierung - Umwandlung des erkannten Formats in UTF-8
|
||||||
import uuid # zur Generierung von neuen UUIDs
|
import csv # zur Verarbeitung von .csv Dateien
|
||||||
|
import uuid # zur Generierung von neuen UUIDs
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Flags / globale Variablen #
|
# Flags / globale Variablen #
|
||||||
|
|
||||||
del_zeros = False # Boolean, ob führende Nullen bei Klassen entfernt werden sollen
|
del_zeros = False # Boolean, ob führende Nullen bei Klassen entfernt werden sollen
|
||||||
get_typos = False # Boolean, ob geringe Unterschiede zwischen den Listen ausgegeben werden sollen
|
get_typos = False # Boolean, ob geringe Unterschiede zwischen den Listen ausgegeben werden sollen
|
||||||
test_user = [] # Array in dem Spezialuser gespeichert und wieder eingefügt werden
|
test_user = [] # Array in dem Spezialuser gespeichert und wieder eingefügt werden
|
||||||
|
|
||||||
school_id = 'HL' # HL-Tag für Klassen
|
school_id = 'HL' # HL-Tag für Klassen
|
||||||
ox_context = 0 # OX Context pro Schule
|
ox_context = 0 # OX Context pro Schule
|
||||||
mail_quota_lul = 2048 # MailUserQuota LuL
|
mail_quota_lul = 2048 # MailUserQuota LuL
|
||||||
ox_quota_lul = 20480 # oxUserQuota LuL
|
ox_quota_lul = 20480 # oxUserQuota LuL
|
||||||
mail_quota_sus = 1024 # MailUserQuota SuS
|
mail_quota_sus = 1024 # MailUserQuota SuS
|
||||||
ox_quota_sus = 5120 # oxUserQuota LuL
|
ox_quota_sus = 5120 # oxUserQuota LuL
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# MAIN FUNCTION START #
|
# MAIN FUNCTION START #
|
||||||
@@ -50,6 +51,8 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
del_zeros = True
|
del_zeros = True
|
||||||
|
|
||||||
|
# step1.check_file()
|
||||||
|
|
||||||
# ---------------------------------------------------- #
|
# ---------------------------------------------------- #
|
||||||
# Step 2 - auf name, vorname reduzieren und abgleichen #
|
# Step 2 - auf name, vorname reduzieren und abgleichen #
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
panads
|
panads
|
||||||
chardet
|
chardet~=5.2.0
|
||||||
|
Kivy~=2.3.0
|
||||||
|
pandas~=2.0.3
|
||||||
|
Levenshtein~=0.23.0
|
||||||
40
src/step1.py
40
src/step1.py
@@ -0,0 +1,40 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import chardet
|
||||||
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
# prüft aktuelles Format mittels chardet Lib
|
||||||
|
def check_export_file(path):
|
||||||
|
with open(path, 'rb') as file:
|
||||||
|
result = chardet.detect(file.read())
|
||||||
|
|
||||||
|
detected_encoding = result['encoding']
|
||||||
|
|
||||||
|
# Try: Datei in pandas einlesen
|
||||||
|
try:
|
||||||
|
return pd.read_csv(path, encoding=detected_encoding)
|
||||||
|
# Catch: zusätzliche Kommas entfernen
|
||||||
|
except pd.errors.ParserError as e:
|
||||||
|
# Wenn ein Parserfehler auftritt, gibt eine Fehlermeldung aus
|
||||||
|
print(f"Fehler beim Einlesen der CSV-Datei: {e}")
|
||||||
|
print()
|
||||||
|
data = open(path, "r")
|
||||||
|
data = ''.join([i for i in data]).replace(",", "")
|
||||||
|
x = open(path, "w")
|
||||||
|
x.writelines(data)
|
||||||
|
x.close()
|
||||||
|
print(f"Alle Kommas entfernt, einlesen wir erneut versucht ...")
|
||||||
|
# Nach Komma Ersetzung erneut versuchen
|
||||||
|
try:
|
||||||
|
return pd.read_csv(path, encoding=detected_encoding)
|
||||||
|
except pd.errors.ParserError as e:
|
||||||
|
print(f"Erneut Fehler in CSV-Datei: {e}")
|
||||||
|
print(f"Datei muss manuell geändert werden.")
|
||||||
|
|
||||||
|
|
||||||
|
# zum Einlesen der bisherigen Systemdaten
|
||||||
|
def create_dataframe_system(path):
|
||||||
|
try:
|
||||||
|
return pd.read_csv(path, encoding='utf')
|
||||||
|
except pd.errors.ParserError as e:
|
||||||
|
print(f"Fehler beim Einlesen der CSV")
|
||||||
|
|||||||
Reference in New Issue
Block a user