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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -