aregak
aregak

Reputation: 237

python loading several matlab files

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

Upvotes: 1

Views: 4091

Answers (1)

Mike Ounsworth
Mike Ounsworth

Reputation: 2504

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]
...

Upvotes: 7

Related Questions