Skip to content

Commit

Permalink
added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Wegner committed Oct 30, 2023
1 parent 3496839 commit ff993aa
Show file tree
Hide file tree
Showing 3 changed files with 1,043 additions and 210 deletions.
5 changes: 3 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,11 @@ async def ai_mapping_2_csv(csvFile: UploadFile, variableColumnName: str = "Varia


## try different encodings
encodings = ["utf-8", "unicode_escape", "cp1252", "ISO-8859-1", "", "ENDING"]

for encoding in ["utf-8", "unicode_escape", "cp1252", "ISO-8859-1", "", "ENDING"]:
for encoding in encodings:
if encoding == "ENDING":
return Response(status_code=500, content=f"Could not read csv file. Please Check encoding --> utf-8 required", media_type="text/plain")
return Response(status_code=500, content=f"Could not read csv file. Please Check encoding -->one of {encodings} required", media_type="text/plain")
try:
df = pd.read_csv(io.StringIO(file_content.decode('utf-8')), sep=delimiter, encoding=encoding)
break
Expand Down
Loading

0 comments on commit ff993aa

Please sign in to comment.