import pickle import os # small module to handle quick saving and loading of (pre-analyzed) data (for figures) def save(python_object, path, create_folders=True): """ save a python object in a file, creates all necessary the folders """ if create_folders and not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) with open(path, 'wb') as file: pickle.dump(python_object, file) def load(path): """ load pickled python object saved in the file at path. """ with open(path, "rb") as file: py_object = pickle.load(file) return py_object