Added new method to retreive metadata from h5file at a given obj path
This commit is contained in:
@ -100,6 +100,19 @@ class HDF5DataOpsManager():
|
||||
annotation_dict[new_attr_key] = utils.parse_attribute(annotation_dict[new_attr_key])
|
||||
obj.attrs.update(annotation_dict)
|
||||
|
||||
def get_metadata(self, obj_path):
|
||||
""" Get file attributes from object at path = obj_path. For example,
|
||||
obj_path = '/' will get root level attributes or metadata.
|
||||
"""
|
||||
try:
|
||||
# Access the attributes for the object at the given path
|
||||
metadata_dict = self.file_obj[obj_path].attrs
|
||||
except KeyError:
|
||||
# Handle the case where the path doesn't exist
|
||||
logging.error(f'Invalid object path: {obj_path}')
|
||||
metadata_dict = {}
|
||||
|
||||
return metadata_dict
|
||||
|
||||
def reformat_datetime_column(self, dataset_name, column_name, src_format, desired_format='%Y-%m-%d %H:%M:%S.%f'):
|
||||
# Access the dataset
|
||||
@ -165,11 +178,6 @@ def read_dataset_from_hdf5file(hdf5_file_path, dataset_path):
|
||||
#metadata_df = pd.DataFrame.from_dict(data, orient='columns')
|
||||
return df
|
||||
|
||||
def read_metadata_from_hdf5obj(hdf5_file_path, obj_path):
|
||||
# TODO: Complete this function
|
||||
metadata_df = pd.DataFrame.empty()
|
||||
return metadata_df
|
||||
|
||||
def list_datasets_in_hdf5file(hdf5_file_path):
|
||||
|
||||
def get_datasets(name, obj, list_of_datasets):
|
||||
|
Reference in New Issue
Block a user