python - Writing numpy arrays to files -


i want know if numpy has build-in functions writing files or if there method, should used writing array constructed this:

[[2, 3, 4], [3, 5, 6], [8, 7, 9]] 

to file looks this:

2 3 4  3 5 6 8 7 9 

i not sure how this. know how regular python list using loop want know way should done.

you can use

np.savetxt( "filename.txt", your_array ) 

for details see: http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.savetxt.html

[update] can use formatting parameter e.g. this:

your_array = [[2, 3, 4], [3, 5, 6], [8, 7, 9]] np.savetxt("filename.txt", your_array, fmt="%d") 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -