-1

I have a 2-dimensional array. I want to save this array in a text file and then I want to retrieve this array using python.

My code:

np.savetxt('points.txt',final_points)
f=open('points.txt','r')
new_final_points=f.read()

This saves the whole array as a string in new_final_points. I want it back in the array form.

Michael Szczesny
  • 4,911
  • 5
  • 15
  • 32

1 Answers1

1

You can use numpy's np.loadtxt in very much the same way as np.savetxt

Example:

np.savetxt("points.txt")
array = np.loadtxt("points.txt")
RossM
  • 438
  • 4
  • 10