3

I have a csv file and I have transformed it in an h5 file with pandas:

data = pd.read_csv('file.csv')
data.to_hdf('file.h5', 'table')

Now I would like to read it with matlab.

How can I do that?

I have tried

data = h5read('file.h5','/g4/lat');

but I get:

Error using h5readc
The HDF5 library encountered an error and produced the
following stack trace information:

    H5G_traverse_real    component not found
    H5G_traverse         internal path traversal failed
    H5G_loc_find         can't find object
    H5Dopen2             not found

Error in h5read (line 58)
[data,var_class] =
h5readc(Filename,Dataset,start,count,stride);

Error in read_time_series (line 4)
data = h5read(data_path,'/g4/lat');
Donbeo
  • 17,067
  • 37
  • 114
  • 188
  • Is `/g4/lat` your dataset name? – macduff May 22 '15 at 16:28
  • pandas (via pytables) attaches a lot more metadata *on top* of HDF5. Matlab probably won't be able to read it. You may have luck using H5py, possible via [odo](http://odo.readthedocs.org/en/latest/hdf5.html), which understands pandas-style and native HDF5. – TomAugspurger May 22 '15 at 16:36
  • no the name is `data_path` the second argument was copied from the matlab documentation but I do not know its meaning – Donbeo May 22 '15 at 17:16
  • How about reading directly the csv-file in Matlab? – A. Donda May 23 '15 at 00:39

1 Answers1

1

You need to export with format='table', see docs here.

This is can be read by various R packages and should be ok in matlab, as this is plain vanilla HDF5, which some meta-data attached (which is probably not read automatically).

Jeff
  • 125,376
  • 21
  • 220
  • 187