Skip to content

Commit

Permalink
Merge pull request #206 from mccalluc/parse-epw-as-latin-1
Browse files Browse the repository at this point in the history
Parse EPW as Latin-1, so that non-ASCII characters do not error
  • Loading branch information
FedericoTartarini authored Nov 13, 2023
2 parents c5697bc + a9a2188 commit e4aeaa5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions my_project/tab_select/app_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,15 @@ def submitted_data(
):
content_type, content_string = list_of_contents[0].split(",")

decoded = base64.b64decode(content_string)
decoded_bytes = base64.b64decode(content_string)
try:
if "epw" in list_of_names[0]:
# Assume that the user uploaded a CSV file
lines = io.StringIO(decoded.decode("utf-8")).read().split("\n")
try:
decoded_string = decoded_bytes.decode("utf-8")
except UnicodeDecodeError:
decoded_string = decoded_bytes.decode("latin-1")
lines = decoded_string.split("\n")
df, location_info = create_df(lines, list_of_names[0])
return (
location_info,
Expand Down

0 comments on commit e4aeaa5

Please sign in to comment.