varun...@gmail.com wrote: > Hello everyone, > > I recently came across a package called matrix2latex which simplifies the > creation of very large tables. So, I saved my data in .mat format using > the '-v7.3' extension so that they can be read by python. > > Now, when I try to read these files, I'm having some problems in > reproducing the whole matrix. Whenever I try and print out an element of > the array, I only get 'HDF5 object reference' as the output. This is > basically the short code I wrote and what I basically want to do is have > the values of the elements in the arrays and not the 'HDF5 object > reference' thing. ex [ [ 1 2 3 4 ], [2 3 4 5 ]...] > > Could you please help me with this? The link to the .mat file is as below > > https://drive.google.com/file/d/0B2-j91i19ey2Nm1CbVpCQVdZc3M/view?usp=sharing > > > import numpy as np, h5py > from matrix2latex import matrix2latex > > f = h5py.File('nominal_case_unfix.mat', 'r') > data = f.get('nominal_case_unfix')
Did you mean _fix instead of _unfix? > np_data = np.array(data) > print np_data Maybe it has something to do with the way you saved your data? When I save and load a matrix I don't see those object references: $ cat h5write.py import numpy as np import h5py a = np.array([[1,2,3], [4,5,6]]) f = h5py.File('save.mat', 'w') d = f.create_dataset("foo", data=a) f.close() $ python h5write.py $ cat h5read.py import sys import numpy as np import h5py filename, matrixlocation = sys.argv[1:] f = h5py.File(filename, 'r') d = f.get(matrixlocation) print np.array(d) $ python h5read.py save.mat foo [[1 2 3] [4 5 6]] However, with your data set: $ python h5read.py nominal_case_fix.mat nominal_case_fix [[<HDF5 object reference> <HDF5 object reference> <HDF5 object reference> [...] <HDF5 object reference> <HDF5 object reference> <HDF5 object reference>]] $ -- https://mail.python.org/mailman/listinfo/python-list