summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py44
1 files changed, 28 insertions, 16 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index d47a9ffd2..f69ca0c73 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -285,21 +285,23 @@ def load(file, mmap_mode=None):
Parameters
----------
file : file-like object or string
- The file to read. It must support ``seek()`` and ``read()`` methods.
- If the filename extension is ``.gz``, the file is first decompressed.
+ The file to read. Compressed files with the filename extension
+ ``.gz`` are acceptable. File-like objects must support the
+ ``seek()`` and ``read()`` methods. Pickled files require that the
+ file-like object support the ``readline()`` method as well.
mmap_mode : {None, 'r+', 'r', 'w+', 'c'}, optional
- If not None, then memory-map the file, using the given mode
- (see `numpy.memmap` for a detailed description of the modes).
- A memory-mapped array is kept on disk. However, it can be accessed
- and sliced like any ndarray. Memory mapping is especially useful for
- accessing small fragments of large files without reading the entire
- file into memory.
+ If not None, then memory-map the file, using the given mode (see
+ `numpy.memmap` for a detailed description of the modes). A
+ memory-mapped array is kept on disk. However, it can be accessed
+ and sliced like any ndarray. Memory mapping is especially useful
+ for accessing small fragments of large files without reading the
+ entire file into memory.
Returns
-------
result : array, tuple, dict, etc.
- Data stored in the file. For ``.npz`` files, the returned instance of
- NpzFile class must be closed to avoid leaking file descriptors.
+ Data stored in the file. For ``.npz`` files, the returned instance
+ of NpzFile class must be closed to avoid leaking file descriptors.
Raises
------
@@ -308,7 +310,7 @@ def load(file, mmap_mode=None):
See Also
--------
- save, savez, loadtxt
+ save, savez, savez_compressed, loadtxt
memmap : Create a memory-map to an array stored in a file on disk.
Notes
@@ -319,13 +321,14 @@ def load(file, mmap_mode=None):
- If the file is a ``.npz`` file, then a dictionary-like object is
returned, containing ``{filename: array}`` key-value pairs, one for
each file in the archive.
- - If the file is a ``.npz`` file, the returned value supports the context
- manager protocol in a similar fashion to the open function::
+ - If the file is a ``.npz`` file, the returned value supports the
+ context manager protocol in a similar fashion to the open function::
with load('foo.npz') as data:
a = data['a']
- The underlying file descriptor is closed when exiting the 'with' block.
+ The underlying file descriptor is closed when exiting the 'with'
+ block.
Examples
--------
@@ -549,6 +552,7 @@ def savez_compressed(file, *args, **kwds):
See Also
--------
numpy.savez : Save several arrays into an uncompressed ``.npz`` file format
+ numpy.load : Load the files created by savez_compressed.
"""
_savez(file, args, kwds, True)
@@ -1195,14 +1199,20 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
The string used to separate values. By default, any consecutive
whitespaces act as delimiter. An integer or sequence of integers
can also be provided as width(s) of each field.
+ skip_rows : int, optional
+ `skip_rows` was deprecated in numpy 1.5, and will be removed in
+ numpy 2.0. Please use `skip_header` instead.
skip_header : int, optional
- The numbers of lines to skip at the beginning of the file.
+ The number of lines to skip at the beginning of the file.
skip_footer : int, optional
- The numbers of lines to skip at the end of the file
+ The number of lines to skip at the end of the file.
converters : variable, optional
The set of functions that convert the data of a column to a value.
The converters can also be used to provide a default value
for missing data: ``converters = {3: lambda s: float(s or 0)}``.
+ missing : variable, optional
+ `missing` was deprecated in numpy 1.5, and will be removed in
+ numpy 2.0. Please use `missing_values` instead.
missing_values : variable, optional
The set of strings corresponding to missing data.
filling_values : variable, optional
@@ -1240,6 +1250,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
usemask : bool, optional
If True, return a masked array.
If False, return a regular array.
+ loose : bool, optional
+ If True, do not raise errors for invalid values.
invalid_raise : bool, optional
If True, an exception is raised if an inconsistency is detected in the
number of columns.