def recover_matrix(config, directory='.'):
"""Recover a matrix by either its config or uuid.
Parameters
----------
config: str or dict
config metadata for the matrix or uuid
directory: str
path to search for the matrix
Returns
-------
df_matrix: DataFrame
DataFrame of specified matrix
None:
If no matrix matrix is found
"""
if isinstance(config, dict):
uuid = generate_uuid(config)
else:
uuid = config
fname = directory + '/' + uuid
if os.path.isfile(fname + '.h5'):
df_matrix = pd.read_hdf(fname + '.h5')
return df_matrix
elif os.path.isfile(fname + '.csv'):
df_matrix = pd.read_csv(fname + '.csv')
return df_matrix
else:
return None
评论列表
文章目录