Skip to content

Commit 42d5b79

Browse files
authored
Merge pull request #582 from mapping-commons/gz-reader
Handle gzipped SSSOM files
2 parents 3a99103 + c70fa3a commit 42d5b79

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/sssom/parsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""SSSOM parsers."""
22

3+
import gzip
34
import io
45
import itertools as itt
56
import json
@@ -96,6 +97,10 @@ def _open_input(input: Union[str, Path, TextIO]) -> io.StringIO:
9697
elif "\n" in input or "\r" in input:
9798
# It's string data
9899
return io.StringIO(input)
100+
elif input.endswith(".gz"):
101+
with gzip.open(input, "rt") as file:
102+
file_content = file.read()
103+
return io.StringIO(file_content)
99104
else:
100105
# It's a local file path
101106
with open(input, "r") as file:

0 commit comments

Comments
 (0)