Skip to content

Commit

Permalink
Merge pull request #177 from neutrinoceros/hotfix_pandas_2.2_compat
Browse files Browse the repository at this point in the history
BUG: fix incompatibility with pandas>=2.2
  • Loading branch information
agurvich authored Jan 23, 2024
2 parents f65a59f + eebb2cc commit c3f0ddf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/firefly/data_reader/json_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import os
import json

def write_to_json(dictionary,path=None):
"""Simple utility function to write a dictionary to a path as :code:`.json` file.
Expand All @@ -25,7 +26,9 @@ def load_from_json(path):
:return: dictionary
:rtype: dict
"""
if os.path.isfile(path):
with open(path,'r') as handle:
dictionary=pd.io.json.loads(''.join(handle.readlines()))
if not os.path.isfile(path):
raise FileNotFoundError(path)

with open(path,'r') as handle:
dictionary = json.load(handle)
return dictionary

0 comments on commit c3f0ddf

Please sign in to comment.