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
Post a Comment