From 5a14efcef4a60ccb268cf76ec0101eb327289281 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Thu, 25 Nov 2021 11:16:51 -0800 Subject: [PATCH] Handle missing input file explicitly Check for and raise an exception when the user passes a non-existing file as input. This makes such errors easier to identify, as opposed to the code path and exception that is raised with a non-existing file is passed (which also happens to be the same exception raised when a non-XLSX file is passed, making this error confusing). --- xlsx2csv.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xlsx2csv.py b/xlsx2csv.py index fe7874b..01c6a4d 100755 --- a/xlsx2csv.py +++ b/xlsx2csv.py @@ -1190,6 +1190,8 @@ def convert_recursive(path, sheetid, outfile, kwargs): try: if os.path.isdir(options.infile): convert_recursive(options.infile, sheetid, outfile, kwargs) + elif not os.path.exists(options.infile): + raise InvalidXlsxFileException("Input file not found!") else: xlsx2csv = Xlsx2csv(options.infile, **kwargs) if options.sheetname: