Reading MATLAB .MAT Files

Is there a method within KNIME to import MATLAB MAT files?  I've previously imported *.csv data with great success but don't really want to write a conversion script in python/MATLAB unless I have to...  

There is a matlab extension, did you check if this is possible with it?

We don't have a native node which can read the files

The MATLAB scripting extension is broken for me, and has been for some time.

There's an R package R.matlab which says it can read .mat files. Perhaps you could use that in an R script node.

Hello :slight_smile:
i have a nice code that solves my matlab.mat file reading problem

myFile= h5py.File(‘matfile.mat’,‘r’)
myData = myFile.get(‘DATA’).value
output_table = pd.DataFrame(np.array(myData))

As a quick fix i executed that code in the “DL Python Network Executor”.
Can anyone tell me what would be the proper node for that?
Thx!!

How about a Python Script 1:1 node?

2 Likes

Hey @ScottF ,
thanks for your reply!
I tried “python object reader”, but this one has a “blue square” output and does not fit to e.g. “column splitter”.
The “python Script (1=>1)” is better, but still requires an input. So i can use “Table Creator” to produce an dummy input. Which is still not very elegant.
If there was “python Script (0=>1)” that would be ideal :slight_smile:

Cheers
Niko

Hey @niko314159,

there is a Python Source node which doesn’t require an input. :slight_smile:

Cheers,
Julian

2 Likes

Hey @julian.bunzel,

now we got it. THX!!
Since i spend (too much :wink: ) time on that… here the summary:
Load matlab -v7.3 .mat files with KNIME using python 3.6
Take the “python source” node with
myFile = h5py.File(‘matfile.mat’,‘r’)
myData = myFile.get(‘DATA’).value
output_table = pd.DataFrame(np.array(myData))
Have fun :slight_smile:

3 Likes