You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / lib / _npyio_impl / _read

function

numpy.lib._npyio_impl:_read

source: /numpy/lib/_npyio_impl.py :861

Signature

def   _read ( fname * delimiter = , comment = # quote = " imaginary_unit = j usecols = None skiplines = 0 max_rows = None converters = None ndmin = None unpack = False dtype = <class 'numpy.float64'> encoding = None )

Summary

Read a NumPy array from a text file. This is a helper function for loadtxt.

Parameters

fname : file, str, or pathlib.Path

The filename or the file to be read.

delimiter : str, optional

Field delimiter of the fields in line of the file. Default is a comma, ','. If None any sequence of whitespace is considered a delimiter.

comment : str or sequence of str or None, optional

Character that begins a comment. All text from the comment character to the end of the line is ignored. Multiple comments or multiple-character comment strings are supported, but may be slower and quote must be empty if used. Use None to disable all use of comments.

quote : str or None, optional

Character that is used to quote string fields. Default is '"' (a double quote). Use None to disable quote support.

imaginary_unit : str, optional

Character that represent the imaginary unit sqrt(-1). Default is 'j'.

usecols : array_like, optional

A one-dimensional array of integer column numbers. These are the columns from the file to be included in the array. If this value is not given, all the columns are used.

skiplines : int, optional

Number of lines to skip before interpreting the data in the file.

max_rows : int, optional

Maximum number of rows of data to read. Default is to read the entire file.

converters : dict or callable, optional

A function to parse all columns strings into the desired value, or a dictionary mapping column number to a parser function. E.g. if column 0 is a date string: converters = {0: datestr2num}. Converters can also be used to provide a default value for missing data, e.g. converters = lambda s: float(s.strip() or 0) will convert empty fields to 0. Default: None

ndmin : int, optional

Minimum dimension of the array returned. Allowed values are 0, 1 or 2. Default is 0.

unpack : bool, optional

If True, the returned array is transposed, so that arguments may be unpacked using x, y, z = read(...). When used with a structured data-type, arrays are returned for each field. Default is False.

dtype : numpy data type

A NumPy dtype instance, can be a structured dtype to map to the columns of the file.

encoding : str, optional

Encoding used to decode the inputfile. The special value 'bytes' (the default) enables backwards-compatible behavior for converters, ensuring that inputs to the converter functions are encoded bytes objects. The special value 'bytes' has no additional effect if converters=None. If encoding is 'bytes' or None, the default system encoding is used.

Returns

: ndarray

NumPy array.

Aliases

  • numpy.lib._npyio_impl._read