0

I have a very big matlab data file(2GB) which I need to load in python with scipy.io.loadmat. It returns MemoryError. It is surely because the file is too big, loading it in matlab in the same machine return memory error, either.

But load a sequence of variables of this file succeed like this, scipy,io,loadmat('data.mat',variable_names='var1'). So I need get a list of all variables inside a mat file, without first loading the file, then data.keys().

Anyone knows how?

1 Answer 1

3

To get a list of all the variables in a .mat file, you can use scipy.io.whosmat:

>>> import numpy as np, scipy.io
>>> md = {"A": np.random.random((100,3)), "B": np.zeros((1,2,3), dtype=int)}
>>> scipy.io.savemat("test.mat", md)
>>> scipy.io.whosmat("test.mat")
[('A', (100, 3), 'double'), ('B', (1, 2, 3), 'int32')]

(Whether this is the best approach to your actual problem, I've no idea.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.