Load in data to Python from .mat that contains multiple structs for each id?

Issue

This Content is from Stack Overflow. Question asked by Cmagelssen

I have a large dataset in Matlab that I want to convert into a data frame in Python. The dataset is a 1*17 struct (one for each participant in an experiment). Each participant also has a struct with many variables that I am keen to analyze. So I am looking for a solution that helps me do this.

For Python, I found this documentation quite useful: https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html

Using this information I have loaded the .mat file into python with the following code:

from scipy.io import loadmat

matlabData = loadmat(r"LPS_IMU_Struct060621_Done.mat")
data = matlabData['LPS_Struct']
data.dtype

# Which return this information:
# dtype([('Name', 'O'), ('Table', 'O'), ('Array', 'O'), ('Time', 'O'), ('IMU_Number', 'O'), ('Cutted_Array', 'O'), ('ArrayRotated', 'O'), ('RunIndex', 'O'), ('Run_New_Index', 'O'), ('ArrayRotatedMoved', 'O'), ('IMU_Table', 'O')])

But I don’t understand what I should do next. A helpful resource I found was this youtube video. But it doesn’t seem to work in my case because I a many structs for each person. Is there a way to solve this problem?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?