Search code examples
pythonhdf5pytablesh5py

Rename a column within a HDF5 file


I am looking to rename a column within one of my HDF5 file to something else but I cannot fathom how to do it.

>>> h5 = h5py.File(hdf5file, 'r')
>>> h5['/ook'].dtype
dtype([('fubar', '<f4'), ... )]

I want to rename 'fubar' to something else. Clearly, I want to rename all the first elements of the dtype, not just the first one.

Using h5dump, the data I want to rename is described as this:

  DATASET "log" {
      DATATYPE  H5T_COMPOUND {
         H5T_IEEE_F32LE "fubar";
         ...

Finally, I did try this:

>>> h5['/log'].dtype.names = ('0', ...)

But, again no luck there.


Solution

  • It appears that this is not possible because it is expressly forbidden in the specification.