Empty readout for a Data table from from h5 file: a weird problem


#1

Hello, I have a problem reading an h5 file.

I just want to read a Data table(Scalar Dataset) from the file using the Matlab code:

    filepath = 'D:\QMDownload\3\new.h5';
    plist = 'H5P_DEFAULT';
    fid = H5F.open(filepath); 
    dataset_id = H5D.open(fid,'/Scene8/Data');
    data = H5D.read(dataset_id);
    H5D.close(dset_id);
    H5F.close(fid);

The data I got is empty. So I open in HDF5 viewer to see why it is empty. When I double-click /Scene8/Data to show this table in HDF viewer, it takes more than 40 seconds to respond. (However, other Dataset in this file opens immediately no matter big or small). This table was strange that it has only 1 cell. I found that the cell has a very long explicit string typing 88411 numbers joined by comma. When I copy the long string and input into Matlab command window, I get a vector with 1x88411. When I convert it to AscII, I found that it is a standard long xml document.

My problem is that although I can read all the other dataset and attributes in this file, I cannot read this table into Matlab workspace by code above. It’s always empty.

I tried to delete inside this file all the content except this table. Then I double-click this table again in HDF viewer, however, it says that “could not open dataset ”Data”, dimension is zero”.

Can anyone help me on this problem?
Thanks

The file is

https://drive.google.com/file/d/1XigsXSzufb8kAo4ax6_nfDa1zIpXBF5N/view?usp=sharing


#2

Please use h5dump -H to examine the internal structure of that dataset. It looks like the h5 file was written in some way other than what you expected.


#3

After dumping, the table correspond to the info below
DATASET “Data” {
DATATYPE H5T_VLEN { H5T_STD_I8LE}
DATASPACE SIMPLE { ( 0 ) / ( H5S_UNLIMITED ) }
}


#4

The short answer is, this is an empty data set because the dimension length is zero. Your data set was not created properly. Please review the creation of your original file.

The longer answer is, you should study basic HDF5 documentation about data sets. I recommend the sections about datatypes and datasets here:

You said that other data sets in the same file can be opened immediately. You might find it helpful to look at the structure of other working datasets with h5dump -H, and compare with the non-working one.