switch from chardet to charset-normalizer
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
import csv
|
import csv
|
||||||
|
from charset_normalizer import detect
|
||||||
import chardet
|
|
||||||
|
|
||||||
|
|
||||||
def csv_to_list(path: str) -> list[str]:
|
def csv_to_list(path: str) -> list[str]:
|
||||||
"""
|
"""
|
||||||
Extracts the data from a csv file and returns it as a pandas dataframe
|
Extracts the data from a csv file and returns it as a pandas dataframe
|
||||||
"""
|
"""
|
||||||
encoding = chardet.detect(open(path, "rb").read())["encoding"]
|
encoding = detect(open(path, "rb").read())["encoding"]
|
||||||
with open(path, newline="", encoding=encoding) as csvfile:
|
with open(path, newline="", encoding=encoding) as csvfile:
|
||||||
# if decoder fails to map, assign ""
|
# if decoder fails to map, assign ""
|
||||||
reader = csv.reader(csvfile, delimiter=";", quotechar="|")
|
reader = csv.reader(csvfile, delimiter=";", quotechar="|")
|
||||||
|
|||||||
Reference in New Issue
Block a user