Home > Software design >  Spliting .mat file
Spliting .mat file

Time:12-06

Hi I'm having a problem splitting .mat file into separated values

Here is how I load files

import scipy.io 

szum_1 = scipy.io.loadmat('szum_1.mat')['szum_1']
szum_2 = scipy.io.loadmat('szum_2.mat')['szum_2']

And output:

[ 3.29420368  2.2221562   1.9350699   1.23158597  2.57708046  1.94689757 etc.]

So as you can see it's a whole bunch of values packed into one cell

I've tried using np.char.split(szum_1[0], sep=' ') but I got an error 'string operation on non-string array' and I have no other idea on how to split these numbers

CodePudding user response:

split works only for strings, so you should convert the numbers into strings using str()

import scipy.io 
szum_1 = str(scipy.io.loadmat('szum_1.mat')['szum_1'])
szum_2 = str(scipy.io.loadmat('szum_2.mat')['szum_2'])
  • Related