export matlab data to python
I have a sentence ' i am unhappy' stored in variable 'a' in matlab. i want to extract data from matlab to python.
like if i write 'a' in python, it should display the whole sentence stored in MATLAB. and yes further i want to convert that sentence into speech using gtts.
i have tried,this:
from scipy.io import loadmat
test = loadmat('value.mat')
but it gives error:
MatReadWarning: Duplicate variable name "None" in stream - replacing
previous with new Consider mio5.varmats_from_mat to split file into
single variable files matfile_dict = MR.get_variables(variable_names)
python import export workspace
add a comment |
I have a sentence ' i am unhappy' stored in variable 'a' in matlab. i want to extract data from matlab to python.
like if i write 'a' in python, it should display the whole sentence stored in MATLAB. and yes further i want to convert that sentence into speech using gtts.
i have tried,this:
from scipy.io import loadmat
test = loadmat('value.mat')
but it gives error:
MatReadWarning: Duplicate variable name "None" in stream - replacing
previous with new Consider mio5.varmats_from_mat to split file into
single variable files matfile_dict = MR.get_variables(variable_names)
python import export workspace
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19
add a comment |
I have a sentence ' i am unhappy' stored in variable 'a' in matlab. i want to extract data from matlab to python.
like if i write 'a' in python, it should display the whole sentence stored in MATLAB. and yes further i want to convert that sentence into speech using gtts.
i have tried,this:
from scipy.io import loadmat
test = loadmat('value.mat')
but it gives error:
MatReadWarning: Duplicate variable name "None" in stream - replacing
previous with new Consider mio5.varmats_from_mat to split file into
single variable files matfile_dict = MR.get_variables(variable_names)
python import export workspace
I have a sentence ' i am unhappy' stored in variable 'a' in matlab. i want to extract data from matlab to python.
like if i write 'a' in python, it should display the whole sentence stored in MATLAB. and yes further i want to convert that sentence into speech using gtts.
i have tried,this:
from scipy.io import loadmat
test = loadmat('value.mat')
but it gives error:
MatReadWarning: Duplicate variable name "None" in stream - replacing
previous with new Consider mio5.varmats_from_mat to split file into
single variable files matfile_dict = MR.get_variables(variable_names)
python import export workspace
python import export workspace
edited Nov 24 '18 at 16:13
James Z
11.2k71935
11.2k71935
asked Nov 24 '18 at 14:53
Huda FarooquiHuda Farooqui
83
83
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19
add a comment |
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19
add a comment |
1 Answer
1
active
oldest
votes
I could test it like this and had no problems:
In matlab:
>> a = ' hello mat file'
a =
hello mat file
>> filename = 'test.mat'
filename =
test.mat
>> save(filename)
and then in python:
import scipy.io as scio
data = scio.loadmat('test.mat')
data
Out:
{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Nov 27 10:20:58 2018',
'__version__': '1.0',
'__globals__': ,
'a': array([' hello mat file'], dtype='<U15'),
'filename': array(['test.mat'], dtype='<U8')}
data['a']
Out: array([' hello mat file'], dtype='<U15')
So no error message here.
However, note that in Matlab save
by default saves all content of the current workspace in the mat-file. Could it be possible, that you have created some other variables which perhaps are of an unsupported type?
You could check by simply explicitly saving only your test variable a
:
save(filename, 'a')
Does this lead to an importable mat-file in python?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459372%2fexport-matlab-data-to-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I could test it like this and had no problems:
In matlab:
>> a = ' hello mat file'
a =
hello mat file
>> filename = 'test.mat'
filename =
test.mat
>> save(filename)
and then in python:
import scipy.io as scio
data = scio.loadmat('test.mat')
data
Out:
{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Nov 27 10:20:58 2018',
'__version__': '1.0',
'__globals__': ,
'a': array([' hello mat file'], dtype='<U15'),
'filename': array(['test.mat'], dtype='<U8')}
data['a']
Out: array([' hello mat file'], dtype='<U15')
So no error message here.
However, note that in Matlab save
by default saves all content of the current workspace in the mat-file. Could it be possible, that you have created some other variables which perhaps are of an unsupported type?
You could check by simply explicitly saving only your test variable a
:
save(filename, 'a')
Does this lead to an importable mat-file in python?
add a comment |
I could test it like this and had no problems:
In matlab:
>> a = ' hello mat file'
a =
hello mat file
>> filename = 'test.mat'
filename =
test.mat
>> save(filename)
and then in python:
import scipy.io as scio
data = scio.loadmat('test.mat')
data
Out:
{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Nov 27 10:20:58 2018',
'__version__': '1.0',
'__globals__': ,
'a': array([' hello mat file'], dtype='<U15'),
'filename': array(['test.mat'], dtype='<U8')}
data['a']
Out: array([' hello mat file'], dtype='<U15')
So no error message here.
However, note that in Matlab save
by default saves all content of the current workspace in the mat-file. Could it be possible, that you have created some other variables which perhaps are of an unsupported type?
You could check by simply explicitly saving only your test variable a
:
save(filename, 'a')
Does this lead to an importable mat-file in python?
add a comment |
I could test it like this and had no problems:
In matlab:
>> a = ' hello mat file'
a =
hello mat file
>> filename = 'test.mat'
filename =
test.mat
>> save(filename)
and then in python:
import scipy.io as scio
data = scio.loadmat('test.mat')
data
Out:
{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Nov 27 10:20:58 2018',
'__version__': '1.0',
'__globals__': ,
'a': array([' hello mat file'], dtype='<U15'),
'filename': array(['test.mat'], dtype='<U8')}
data['a']
Out: array([' hello mat file'], dtype='<U15')
So no error message here.
However, note that in Matlab save
by default saves all content of the current workspace in the mat-file. Could it be possible, that you have created some other variables which perhaps are of an unsupported type?
You could check by simply explicitly saving only your test variable a
:
save(filename, 'a')
Does this lead to an importable mat-file in python?
I could test it like this and had no problems:
In matlab:
>> a = ' hello mat file'
a =
hello mat file
>> filename = 'test.mat'
filename =
test.mat
>> save(filename)
and then in python:
import scipy.io as scio
data = scio.loadmat('test.mat')
data
Out:
{'__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Nov 27 10:20:58 2018',
'__version__': '1.0',
'__globals__': ,
'a': array([' hello mat file'], dtype='<U15'),
'filename': array(['test.mat'], dtype='<U8')}
data['a']
Out: array([' hello mat file'], dtype='<U15')
So no error message here.
However, note that in Matlab save
by default saves all content of the current workspace in the mat-file. Could it be possible, that you have created some other variables which perhaps are of an unsupported type?
You could check by simply explicitly saving only your test variable a
:
save(filename, 'a')
Does this lead to an importable mat-file in python?
answered Nov 27 '18 at 9:33
SpghttCdSpghttCd
4,8372313
4,8372313
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459372%2fexport-matlab-data-to-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How did you save what in which version of a mat-file?
– SpghttCd
Nov 24 '18 at 15:13
@SpghttCd i dont know much about this... i just tried this code : filename = 'test.mat'; save(filename)
– Huda Farooqui
Nov 25 '18 at 16:19