Siladittya
Siladittya

Reputation: 1205

Can't pass data from octave to python through command line arguments

I am calculating HoG feature descriptors in Octave and then I am trying to cluster those data in Python using scikit-learn. For testing my code in Python I am trying to pass a 4000x2 data to Python. I am calling the Python script from Octave using

system('python filename.py data')

and then trying to get the data using

sys.argv

but I am getting the second argument as a string 'data' and not the 4000x2 data that I am passing from Octave

What should I do so that I can get the original data in Python and not just the string 'data'

Upvotes: 2

Views: 597

Answers (2)

Tasos Papastylianou
Tasos Papastylianou

Reputation: 22245

There's a python command built into octave. Alternatively, I would save as a .mat file, and open this in your python script using scipy.io.loadmat.

There's also eval_py and python_cmd from the symbolic package, but I'm not sure if this is appropriate for your particular use-case. The most general, matlab-compatible, and recommended way to do this would be the .mat one.

Upvotes: 1

voidpointercast
voidpointercast

Reputation: 185

I am not an expert regarding Octave but the answer is most likely something like that:

command=sprintf("python filename.py %s",data)
system(command)

Be careful that the amount of command line arguments is limited in most operating systems.

Upvotes: 1

Related Questions