Merge multiple H5 in one H5 file in python

I am new in python coding. I want to merge data from 2 h5 files in a main H5 file. In the picture I mention the files from where to copy into which one.

I actually don’t want to iterate into each dataset and create the same in the main file. I just want to get the SRRXX/SRR630/* all groups and add it to the main file.

       #read the mainfile dataset
        with h5py.File(main_h5_path, 'r') as h5_main_file_obj:
            # return if H5 doesn't contain any data
            if len(h5_main_file_obj.keys()) == 0:
                return
            main_file_timestamp_dtset_obj = h5_main_file_obj['/' + 'SRR6XX' + '/' + 'SRR630']

            for file in h5_files:
                with h5py.File(file, 'r') as h5_sub_file_obj:
                    # return if H5 doesn't contain any data
                    if len(h5_sub_file_obj.keys()) == 0:
                        continue
                    sub_file_timestamp_dtset_obj = h5_sub_file_obj['/' + 'SRR6XX' + '/' + 'SRR630']
                    # h5_main_file_obj.create_dataset(sub_file_timestamp_dtset_obj)
                    for ts_key in sub_file_timestamp_dtset_obj.keys():
                        print('ts_key', ts_key)
                        each_ts_ds = h5_sub_file_obj['/' + 'SRR6XX' + '/' + 'SRR630' + '/' + str(ts_key) + '/']
                        h5_main_file_obj.create_dataset(each_ts_ds)


    except (IOError, OSError, Exception) as e:
        print(f"Error occurred during H5 merging: {e}")
        return -1
    return 0

And getting exceptions. Tried create_group() also, but same problem.

“And getting exceptions.”

What exceptions?

group.create_dataset() takes a string as its first argument, specifying the name of the dataset to create. You cannot pass a Dataset object into group.create_dataset(). You can use group.copy() to copy a group or dataset from one file/group to another file/group. You can also use square brackets like target_group[dataset_name] = source_group[dataset_name]. See the documentation for h5py.Group. For more details on the square bracket syntax, see Dict interface and links