Input and output — NumPy v2.6.dev0 Manual

NumPy binary files (npy, npz)

#

The format of these binary file types is documented in

numpy.lib.format

Text files

#

loadtxt

(fname[, dtype, comments, delimiter, ...])

Load data from a text file.

savetxt

(fname, X[, fmt, delimiter, newline, ...])

Save an array to a text file.

genfromtxt

(fname[, dtype, comments, ...])

Load data from a text file, with missing values handled as specified.

fromregex

(file, regexp, dtype[, encoding])

Construct an array from a text file, using regular expression parsing.

fromstring

(string[, dtype, count, like])

A new 1-D array initialized from text data in a string.

ndarray.tofile

(fid, /[, sep, format])

Write array to a file as text or binary (default).

ndarray.tolist

()

Return the array as an a.ndim-levels deep nested list of Python scalars.

Raw binary files

#

String formatting

#

Memory mapping files

#

Text formatting options

#

Text formatting settings are maintained in a

context variable

, allowing different threads or async tasks to have independent configurations. For more information, see

Context Local State

.

Base-n representations

#

Data sources

#

Binary format description

#