How to read .npy files in Matlab

I was wondering if there is a way to read .npy files in Matlab? I know that I can convert them to Matlab .mat files using scipy.io.savemat in Python; however, I'm more interested in supporting native or plug-ins for .npy files in Matlab.

+9
python numpy scipy matlab format-conversion
source share
3 answers

The c ++ library is available https://github.com/rogersce/cnpy.

You can write a mex function to read data. I would rather store everything in hdf5

+5
source share

It helped me, I used it to read npy files.

https://github.com/kwikteam/npy-matlab

If you want to read only the .npy file, all you need from the npy-matlab project is two files: readNPY.m and readNPYheader.m.

Use is as simple as:

 >> im = readNPY('/path/to/file.npy'); 
+10
source share

A quick way would be to read it in Python, as shown below,

 data = np.load('/tmp/123.npz') 

Then save it as ".csv", again through python, using the python documentation or,

 numpy.savetxt('FileName.csv', arrayToSave) 

( more documentation here )

Finally, you can read it in MATLAB using the following command :

 csvread() 
0
source share

All Articles