hdfdict
hdfdict copied to clipboard
Example code is not running
The example script shown in the readme does not appear to run. It throws a FileNotFoundError
. Tested with h5py
version 3.7.0
:
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'test_hdfdict.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
I encountered the same error and didn't manage to solve it. Seems it is related to the importance of doing a f.close()
command after opening a .h5 file as discussed in : https://github.com/h5py/h5py/issues/1066#issue-338414860
For your interest, I found this way of saving dictionary structure in h5 with h5py (pip install h5py
), very useful and easy to reproduce : https://gist.github.com/gilliss/7e1d451b42441e77ae33a8b790eeeb73
Hope it helps, Thomas.
Hi,
I found a work around for this. I create a hdf5 file in the write mode and wrote the dict using hdfdict. Using the following code:
save_file_path = 'sample.h5'
f = h5py.File(save_file_path, 'w')
hdfdict.dump(beam_temp, save_file_path)
f.close()
This is now solved by adding a mode default in the dump()
and load()
function. So it works as intended again.
This error occured due to a change in h5py.