Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • What's the output of the text file? Why not just write to a CSV file? Commented Feb 10, 2015 at 19:05
  • 6
    Do you need to save and load as human-readable text files? It will be faster (and the files will be more compact) if you save/load binary files using np.save() and np.load(). Commented Feb 10, 2015 at 19:11
  • Thank you for your advice. It helped. However, can you explain why it is what it is, and if there is any way to allow saving data in *.txt format and loading it without headache? For example, when one want to work with matlab, java, or other tools/languages. Commented Feb 10, 2015 at 19:14
  • 3
    To pass arrays to/from MATLAB you can use scipy.io.savemat and scipy.io.loadmat. Commented Feb 10, 2015 at 19:24
  • 3
    The default for fromfile is to read the data as binary. loadtxt is the correct pairing with savetxt. Look at the function documentation. Commented Feb 10, 2015 at 19:40