step1.py udated
This commit is contained in:
@@ -8,18 +8,18 @@ def check_file(path):
|
||||
result = chardet.detect(file.read())
|
||||
|
||||
detected_encoding = result['encoding']
|
||||
try:
|
||||
pd.read_csv(path, encoding=detected_encoding)
|
||||
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")
|
||||
# try:
|
||||
# pd.read_csv(path, encoding=detected_encoding)
|
||||
# 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")
|
||||
|
||||
|
||||
# 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']
|
||||
|
||||
# CSV-Datei mit Pandas einlesen
|
||||
# in step1 nicht notwendig, da nicht mit csv, sondern mit pandas frame gearbeitet wird
|
||||
try:
|
||||
df = pd.read_csv(path, encoding=detected_encoding)
|
||||
print("Datei erfolgreich eingelesen.")
|
||||
|
||||
Reference in New Issue
Block a user