Implement method in hdf5 manager to infer datetime column in dataset
This commit is contained in:
@ -96,6 +96,28 @@ class HDF5DataOpsManager():
|
||||
print(f"An unexpected error occurred: {e}. File object will be unloaded.")
|
||||
|
||||
|
||||
def infer_datetime_variable(self,dataset_name):
|
||||
|
||||
if self.file_obj is None:
|
||||
raise RuntimeError("File object is not loaded. Please load the HDF5 file using the 'load_file_obj' method before attempting to extract datasets.")
|
||||
|
||||
metadata_dict = self.get_metadata(dataset_name)
|
||||
|
||||
datetime_var = None
|
||||
datetime_format = None
|
||||
for key in metadata_dict.keys(): # by construction key correspond to column/variable names
|
||||
if not utils.is_structured_array(metadata_dict[key]):
|
||||
continue
|
||||
if 'data_type' in metadata_dict[key].dtype.names:
|
||||
if metadata_dict[key][0]['data_type'].decode() == 'datetime':
|
||||
datetime_var = key
|
||||
datetime_format = metadata_dict[key]['datetime_format'][0].decode()
|
||||
return datetime_var, datetime_format
|
||||
|
||||
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def extract_dataset_as_dataframe(self,dataset_name):
|
||||
|
Reference in New Issue
Block a user