Creating a dataset from an array is easy. Example below loops over all .npy files in a folder and creates 1 dataset for each array. (FYI, I prefer glob.iglob() to get the filenames using a wildcard.) Dataset name is the same as the filename.
import glob
import numpy as np
import h5py
with h5py.File('SO_74788877.h5','w') as h5f:
for filename in glob.iglob('*.npy'):
arr = np.load(filename)
h5f.create_dataset(filename,data=arr)
This code shows how to access the dataset names and values from the H5 file created above. (dataset is a dataset object which behaves like a numpy array in many instances):
with h5py.File('SO_74788877.h5','r') as h5f:
for name, dataset in h5f.items():
print(name, dataset.shape, dataset.dtype)
loadthosenpyfiles? How to iterate over the directory? How to create a HDF5 file withh5py? And creategroupsanddatasets? There pieces are all there.h5pydocumentation is pretty good. But experiment with simple cases first.f. I have no idea what is in the loaded file, nor what attributesfhas. You've not cited any h5py documentation, and have not shown any attempts to create an.hdf5file. I don't know what result you were hoping your question would elicit. Be specific, help us to help you.