Skip to content

Commit

Permalink
Merge pull request #62 from aminebeh/fix/xslx/wrong_encoding_for_xlsx…
Browse files Browse the repository at this point in the history
…_files

fix(xlsx): Fix  error issue for xlsx
  • Loading branch information
ets authored Jan 6, 2024
2 parents f811e40 + a032edf commit 1c9a462
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tap_spreadsheets_anywhere/format_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ def get_row_iterator(table_spec, uri):
reader = get_streamreader(uri, universal_newlines=universal_newlines, open_mode='r', encoding=encoding)
iterator = tap_spreadsheets_anywhere.csv_handler.get_row_iterator(table_spec, reader)
elif format == 'excel':
reader = get_streamreader(uri, universal_newlines=universal_newlines,newline=None, open_mode='rb')
if uri.lower().endswith(".xls"):
reader = get_streamreader(uri, universal_newlines=universal_newlines,newline=None, open_mode='rb')
iterator = tap_spreadsheets_anywhere.excel_handler.get_legacy_row_iterator(table_spec, reader)
else:
# If encoding is set, smart_open will override binary mode ('b' in open_mode) and it will result in a BadZipFile error
reader = get_streamreader(uri, universal_newlines=universal_newlines,newline=None, open_mode='rb', encoding=None)
iterator = tap_spreadsheets_anywhere.excel_handler.get_row_iterator(table_spec, reader)
elif format == 'json':
reader = get_streamreader(uri, universal_newlines=universal_newlines, open_mode='r', encoding=encoding)
Expand Down

0 comments on commit 1c9a462

Please sign in to comment.