Skip to content

Commit

Permalink
Merge pull request #146 from chezou/zero-file
Browse files Browse the repository at this point in the history
fix: adds zero size file check
  • Loading branch information
chezou authored May 3, 2019
2 parents e61d46e + f57022d commit baacafe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tabula/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def read_pdf(input_path,
if not os.path.exists(path):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)

if os.path.getsize(path) == 0:
raise ValueError("{} is empty. Check the file, or download it manually.".format(path))

try:
output = _run(java_options, kwargs, path, encoding)
finally:
Expand Down Expand Up @@ -246,6 +249,9 @@ def convert_into(input_path, output_path, output_format='csv', java_options=None
if not os.path.exists(path):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)

if os.path.getsize(path) == 0:
raise ValueError("{} is empty. Check the file, or download it manually.".format(path))

try:
_run(java_options, kwargs, path)
finally:
Expand Down

0 comments on commit baacafe

Please sign in to comment.