2

I am using hdf5 files to store calibration data. Now I want to use them. But i don't want keep the file open. I whant to do something like this:

fileHandle = h5py.File('calibration.hdf', 'r')
self.xcalib = fileHandle['x']
fileHandle.close()

And then just use xcalib independent of the file. the Problem is now that xcalib is just a h5py group object and will be close when the file is close. Is there a simple way to make it work? so that xcalib is eg. a normal dict. (there are multiple groups and datasets inside)

thanx for every helping comment :)

Edit: So is there no easy way to just make one complete group "offline"?

fileHandle['x']

contains multiple groups and datasets and i want it all copied or whatever. So doing

dict(fileHandle['x'])

just returns

{'0': <HDF5 group "/x/0" (4 members)>, '1': <HDF5 group "/x/1" (4 members)>, '2': <HDF5 group "/x/2" (4 members)>, '3': <HDF5 group "/x/3" (4 members)>}

And when i close the file those HDF5 groups are closed to.

OmegaMatze
  • 61
  • 5
  • 2
    You basically answered your own question... store the data in a dictionary. – mkrieger1 Oct 05 '18 at 08:48
  • Possible duplicate of [How to read HDF5 files in Python](https://stackoverflow.com/questions/28170623/how-to-read-hdf5-files-in-python) – mkrieger1 Oct 05 '18 at 08:49

0 Answers0