December 2017
Intermediate to advanced
386 pages
10h 42m
English
The loadtxt() function reads an array stored using the text format, in particular arrays stored using the savetxt() function. The following line of code reads the array stored in the array_x.txt, which was generated in a previous example:
x = np.loadtxt('array_x.txt')
This code will not produce any output, since the array is silently assigned to the x variable. To see a snapshot of the array, we can execute the following in the command line or Jupyter cell:
x[0:3, 0:3]
This prints the first three rows and columns of the array.
The loadtxt() command offers some flexibility in terms of the format of the text file being read, and has several options to facilitate loading data generated by other software. As ...
Read now
Unlock full access