# H5py: purpose of empty/null datasets?

**URL:** <https://forum.hdfgroup.org/t/h5py-purpose-of-empty-null-datasets/10920>\
**Category:** HDF5 Ancillary Tools\
**Created:** [March 9, 2023, 6:01pm UTC](https://forum.hdfgroup.org/t/h5py-purpose-of-empty-null-datasets/10920 "2023-03-09T18:01:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ken.walker](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/k/b38774/32.png) [@ken.walker](https://forum.hdfgroup.org/u/ken.walker)\
**Post date:** [March 9, 2023, 6:01pm UTC](https://forum.hdfgroup.org/t/h5py-purpose-of-empty-null-datasets/10920/1 "2023-03-09T18:01:14Z")

</div>

While reading the `h5py` docs, I came upon a discussion about creating empty (or null) datasets. (There is also mention of empty/null attributes, but of less interest.) **Ref:** [Creating and Reading Empty (or Null) datasets and attributes](https://docs.h5py.org/en/stable/high/dataset.html#creating-and-reading-empty-or-null-datasets-and-attributes). Per the doc, an empty dataset is “_a dataset with an associated type, but no data, and no shape_”.

From my testing, it appears, you can’t modify the shape or add data to the dataset. Is that correct?

If so, what is the purpose of an empty/null dataset?

---

<div class="post-metadata">

**Author:** ![epourmal1](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/82dd89/32.png) [@epourmal1](https://forum.hdfgroup.org/u/epourmal1)\
**Post date:** [March 9, 2023, 6:44pm UTC](https://forum.hdfgroup.org/t/h5py-purpose-of-empty-null-datasets/10920/2 "2023-03-09T18:44:23Z")

</div>

Originally a “null” dataset (i.e., a dataset that has H5S\_NULL dataspace) was added for the netCDF-4 C library implementation. The purpose of an empty dataset was to hold attributes.

As with any other creation properties, it cannot be changed after the dataset was created; therefore, data cannot be added later.

---

<div class="post-metadata">

**Author:** ![ken.walker](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/k/b38774/32.png) [@ken.walker](https://forum.hdfgroup.org/u/ken.walker)\
**Post date:** [March 9, 2023, 7:50pm UTC](https://forum.hdfgroup.org/t/h5py-purpose-of-empty-null-datasets/10920/3 "2023-03-09T19:50:56Z")

</div>

OK, thanks. It helps to understand the use case.
