1
$\begingroup$

This is the data for one pose. I have a lot of data like this which i want to convert to CSV to apply machine learning algorithm. I am assuming I have to convert this data into a single row of comma separated values which will define a single pose. Any suggestions will be appreciated. enter image description here

$\endgroup$

2 Answers 2

2
$\begingroup$

You can use flatten numpy for this task. Simply convert your data to a numpy array and use the function as:

In [1]: import numpy as np                                                      

In [2]: x = [[[1,2], [3,4]]]                                                    

In [3]: x                                                                       
Out[3]: [[[1, 2], [3, 4]]]

In [4]: np.array(x).flatten()
Out[4]: array([1, 2, 3, 4])
$\endgroup$
0
$\begingroup$

In example starting from

[[[1 2 3]
[5 6 7.3]
[8.2 6 3]]]

and run

<input perl -pe 's/\n//g' | sed -r 's/\]\[/,/g;s/(\[|\])//g;s/\s+/,/g'

you will have

1,2,3,5,6,7.3,8.2,6,3
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.