How to create NULL dataspace using H5Py

Problem

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):

DATASPACE  NULL
DATA {
}

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:

DATASPACE  SCALAR
DATA {
(0): NULL
}

Solution

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

Advertisements

H5Dump

H5Dump

HDF5 is the most popular file format for storing binary data structures. The HDFView tool makes it convenient to view and browse the contents of a HDF5 file in a Java GUI. But what if you are at the commandline and need a way to quickly view or dump the contents of a HDF5 file? The h5dump does exactly this.

  • It can be installed easily:
$ sudo apt install hdf5-tools
  • To dump the contents of a file:
$ h5dump foobar.h5
  • By default, you will notice that some data like string arrays are shown in a matrix format. To display all contents in one column format:
$ h5dump --width=1 foobar.h5
$ h5dump -w 1 foobar.h5

Tried with: HDF5 Tools 1.8.16 and Ubuntu 16.04

HDFView

If you are working with people who use MATLAB, they might sometimes pass you data as a HDF5 file. HDFView is a tool written in Java that can be used to view the contents of such files.

Installing it is easy:

$ sudo apt install hdfview

Open any .h5 file using HDFView and it will display the hierarchy of the contents as a tree on the left. Click on the tree items to view its properties in the bottom. Double-click on the tree items to view its content in the main window.

Tried with: HDFView 2.9 and Ubuntu 14.04