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' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -