how to save a numpy array as a text file code example
Example 1: save numpy array to text file
a_file = open("test.txt", "w")
for row in an_array:
np.savetxt(a_file, row)
a_file.close()
Example 2: how to write a numpy array to a file in python
numpy.savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n',
header='', footer='', comments='# ', encoding=None)
x = y = z = np.arange(0.0,5.0,1.0)
np.savetxt('test.out', x, delimiter=',')
np.savetxt('test.out', (x,y,z))
np.savetxt('test.out', x, fmt='%1.4e')