mydata. , dtype shape.
%.5f, 2d .
savetxt, :
for row in arr:
print(format % tuple(row))
format fmt . , , format - '%.5f,%.5f,%.5f,%.5f,%.5f,%....
tuple , 1d- row , format%().
, .
edit - , 1000 * 30 * 150. 1000 , 30 format. (30,150).
open row ? Py3 'wb'. Iterating yourself on the first dimension means each savetxt call works with a 30x150 array. It will iterate on the 30, and try to format rows of 150. The would create a larger format`, , .
savetxt 2d . 3d . , csv . , .
In [260]: arr = np.arange(24).reshape(4,3,2)
3d - %s:
In [261]: np.savetxt('test',arr, fmt='%s')
In [262]: cat test
[0 1] [2 3] [4 5]
[6 7] [8 9] [10 11]
[12 13] [14 15] [16 17]
[18 19] [20 21] [22 23]
-
In [263]: np.savetxt('test',arr, fmt='%d')
....
TypeError: Mismatch between array dtype ('int32') and format specifier ('%d %d %d')
3d 2d - :
In [264]: np.savetxt('test',arr.reshape(-1,2), fmt='%d')
In [265]: cat test
0 1
2 3
4 5
6 7
8 9
...
22 23
With additional iteration; can add an empty string between blocks
In [267]: with open('test','wb') as f:
...: for row in arr:
...: np.savetxt(f, row, '%d',delimiter=', ')
...:
In [268]: cat test
0, 1
2, 3
4, 5
6, 7
...
22, 23