Closed lauracbell closed 2 years ago
I did the below in the end based on searching through the existing code. I'd suggest to adding this to the jupyter notebook example as it may be helpful to others (who are also relatively new to python).
import json import numpy as np
class NumpyEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.ndarray): return obj.tolist() return json.JSONEncoder.default(self, obj) with open('result.json', 'w') as f: json.dump(result, f, cls=NumpyEncoder, indent=2, sort_keys=True)
Thank you for the easy to read documents with installation and jupyter notebook examples. A simple question is how can I save the results as a json/csv file in interactive use? (I see the flag for command line use.) I've tried json.dump but the ordered dictionary isn't all serializable. If I need to loop over each key, value pair and save, then I can do this, but I feel like I'm missing something simple.