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.PathThe filename or the file to be read.
delimiter: str, optionalField 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, optionalCharacter 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
quotemust be empty if used. Use None to disable all use of comments.quote: str or None, optionalCharacter that is used to quote string fields. Default is '"' (a double quote). Use None to disable quote support.
imaginary_unit: str, optionalCharacter that represent the imaginary unit
sqrt(-1). Default is 'j'.usecols: array_like, optionalA 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, optionalNumber of lines to skip before interpreting the data in the file.
max_rows: int, optionalMaximum number of rows of data to read. Default is to read the entire file.
converters: dict or callable, optionalA 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: Nonendmin: int, optionalMinimum dimension of the array returned. Allowed values are 0, 1 or 2. Default is 0.
unpack: bool, optionalIf 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 typeA NumPy dtype instance, can be a structured dtype to map to the columns of the file.
encoding: str, optionalEncoding 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 ifconverters=None. If encoding is'bytes'orNone, the default system encoding is used.
Returns
: ndarrayNumPy array.
Aliases
-
numpy.lib._npyio_impl._read