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.
2 Answers
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])
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