Skip to content

Commit

Permalink
Enabled removing leading comments from json DB (#83)
Browse files Browse the repository at this point in the history
Encountered a json DB without leading comments.

Added option to adjust the number of expected comments in a json DB.
  • Loading branch information
bnebgen-LANL authored Jul 17, 2024
1 parent 00e0094 commit 9c221a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hippynn/databases/SNAPJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
transpose_cell=True,
allow_unfound=False,
quiet=False,
comments=1,
**kwargs,
):

Expand All @@ -34,6 +35,7 @@ def __init__(
self.targets = targets
self.transpose_cell = transpose_cell
self.depth = depth
self.comments = comments
arr_dict = self.load_arrays(quiet=quiet, allow_unfound=allow_unfound)

super().__init__(arr_dict, inputs, targets, *args, **kwargs, allow_unfound=allow_unfound, quiet=quiet)
Expand Down Expand Up @@ -96,7 +98,8 @@ def filter_arrays(self, arr_dict, allow_unfound=False, quiet=False):

def extract_snap_file(self, file):
with open(file, "rt") as jf:
comment = jf.readline()
for i in range(self.comments):
comment = jf.readline()
content = jf.read()
parsed = json.loads(content)
dataset = parsed["Dataset"]
Expand Down

0 comments on commit 9c221a0

Please sign in to comment.