From ff7e6fcda3c08184e88dc3070ef2f0537fba47ca Mon Sep 17 00:00:00 2001 From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:40:09 +0200 Subject: [PATCH] add encoding detection --- src/logic/csvparser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logic/csvparser.py b/src/logic/csvparser.py index 846a257..3734bb3 100644 --- a/src/logic/csvparser.py +++ b/src/logic/csvparser.py @@ -1,13 +1,13 @@ import csv -import pandas as pdf - +import chardet def csv_to_list(path: str) -> list[str]: """ Extracts the data from a csv file and returns it as a pandas dataframe """ - with open(path, newline="", encoding="utf-8") as csvfile: + encoding = chardet.detect(open(path, "rb").read())["encoding"] + with open(path, newline="", encoding=encoding) as csvfile: # if decoder fails to map, assign "" reader = csv.reader(csvfile, delimiter=";", quotechar="|") ret = []