Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to create NULL dataspace using H5Py

📅 2017-Feb-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ h5py, hdf5 ⬩ 📚 Archive


I was trying to write a HDF5 file using the H5Py package. What I wanted to create was a HDF5 dataset whose dataspace is NULL. This is what I wanted (when dumped by h5dump):


I could not find any input parameters to the create_dataset call that could achieve this. The closest was by passing an empty tuple to the shape parameter.

However, that created a dataset with this structure:

(0): NULL


It turns out that the H5Py had no support to create a NULL dataspace! Thankfully, support for this had just been added to v2.7 as mentioned here.

I used the latest version of H5Py and was able to create a dataset with NULL dataspace. This is done by passing None to the shape parameter.

Tried with: Ubuntu 14.04

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email