Created
September 13, 2015 23:32
-
-
Save sjqtentacles/bc2f69b0c4430211bcad to your computer and use it in GitHub Desktop.
Converting .mat to .csv using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.io | |
import numpy as np | |
data = scipy.io.loadmat("subject.mat") | |
for i in data: | |
if '__' not in i and 'readme' not in i: | |
np.savetxt(("filesforyou/"+i+".csv"),data[i],delimiter=',') |
It works
if it shows 'Mismatch between array dtype ('object') and format specifier' in Python
change the last line:
np.savetxt(("filesforyou/"+i+".csv"),data[i],fmt='%s',delimiter=',')
I am getting following error.
ParserError: Error tokenizing data. C error: Expected 14 fields in line 1117, saw 15
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
TypeError: Mismatch between array dtype ('[('cycle', 'O')]') and format specifier ('%.18e')
yeah this code worked on my macbook 4 years ago, idk if it still does ...
wow I was a shitty programmer back then
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do we need additional python code other scipy and numpy?