dilshod / xlsx2csv

Convert xslx to csv, it is fast, and works for huge xlsx files
MIT License
1.68k stars 303 forks source link

Better handling for when file does not exist. #209

Open stuaxo opened 4 years ago

stuaxo commented 4 years ago

When the file passed in does not exist xlsx2csv should handle this by displaying a message.

(This should also not break things like piping in the output).

Current output when I accidentally wrote import_sheet instead of passing in a file that exists:

Invalid xlsx file: import_sheet
Exception ignored in: <function Xlsx2csv.__del__ at 0x7f3902536dc0>
Traceback (most recent call last):
  File "/home/stu/.virtualenvs/dit-tamato/bin/xlsx2csv", line 210, in __del__
AttributeError: 'Xlsx2csv' object has no attribute 'ziphandle'
corneliusroemer commented 1 year ago

Interesting that this has not been fixed yet - this is one of the most common errors, and the current way it's reported is not ideal:

InvalidXlsxFileException: Invalid xlsx file: 
/Users/corneliusromer/code/nextclade_data_workflows/rsv/clades/aminoa-acid-genotypes.xlsx
Exception ignored in: <function Xlsx2csv.__del__ at 0x1040696c0>
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/py11/lib/python3.11/site-packages/xlsx2csv.py", line 219, in __del__
    self.ziphandle.close()
    ^^^^^^^^^^^^^^
AttributeError: 'Xlsx2csv' object has no attribute 'ziphandle'