Skip to content

Commit

Permalink
Catch UnicodeDecodeError and retry (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ravila4 committed Jul 16, 2022
1 parent cf3cb23 commit 79e09de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hub/dataload/sources/unii/unii_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@


def load_data(input_file):

unii = pd.read_csv(input_file, sep='\t', low_memory=False, dtype=str)
try:
unii = pd.read_csv(input_file, sep='\t', low_memory=False, dtype=str)
except UnicodeDecodeError:
unii = pd.read_csv(input_file, sep='\t', low_memory=False, dtype=str, encoding='windows-1252')

unii.rename(columns={'MF': 'molecular_formula',
'PT': 'preferred_term',
'RN': 'registry_number'}, inplace=True)
Expand Down

0 comments on commit 79e09de

Please sign in to comment.