Skip to content

Commit

Permalink
Merge pull request #93 from zwets/fix-except-on-empty
Browse files Browse the repository at this point in the history
Fix exception on empty input file
  • Loading branch information
fmaguire authored Dec 27, 2024
2 parents 227cd25 + 7e03d2d commit 83478d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hAMRonization/Interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ def __init__(self, source, field_map, metadata):
self.field_map = field_map
self.metadata = metadata

if os.stat(source).st_size == 0:
print(f"Warning: {source} is empty", file=sys.stderr)

try:
if os.stat(source).st_size == 0:
print(f"Warning: {source} is empty", file=sys.stderr)
self.stream = open(source, "r")
except FileNotFoundError: # path doesn't exist
print(f"File {source} not found", file=sys.stderr)
Expand Down

0 comments on commit 83478d9

Please sign in to comment.