1

I was wondering of how I can load several matlab files in python. I am very new to python and don't know much

I am using scipy.io.loadmat('/~/20130228_100000_3D_E=1.mat') and then I save the data in .vts format

How can I do this with all the available matlab files I have by running my program only once?

Thanks

1 Answer 1

7

If all the .mat files are in the same directory, you could do this:

import os

dataDir = "/some/folder/containing/data/"
mats = []
for file in os.listdir( dataDir ) :
    mats.append( scipy.io.loadmat( dataDir+file ) )

You would then have all the matlab files in a list (like arrays in other languages), you can get at them by:

mats[0]
mats[1]
...
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.