I have a getX() which gives a 2D array(shape=(18,2)) as an output for each frame of an image. I want to add this continuously updating array to the csv. I have used the following code. But it is giving me only one row(probably for only one frame).
[array([178., 76.]), array([184., 92.]), array([164., 90.]), array([154., 116.]), array([160., 126.]), array([204., 94.]), array([208., 124.]), array([190., 132.]), array([164., 152.])]
I have tried this:
with open("data.csv",mode ='w') as csvfile:
wr = csv.writer(csvfile, quoting = csv.QUOTE_ALL,dialect="excel")
get_val = oneObject.getX(currentFrameIndex)
for humanPos in get_val:
wr.writerow(humanPos)
np.savetxtis designed to write a 2d array. Internally it is quite simple. It makes input an array if it isn't already, and then just iterates over the rows, doing a python formatted write of thetuple(row). So if your list makes a nice 2d numeric array it should work fine.