MCPcopy Index your code
hub / github.com/numpy/numpy / loadtxt

Function loadtxt

numpy/lib/_npyio_impl.py:1120–1386  ·  view source on GitHub ↗

r""" Load data from a text file. Parameters ---------- fname : file, str, pathlib.Path, list of str, generator File, filename, list, or generator to read. If the filename extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note that generators

(fname, dtype=float, comments='#', delimiter=None,
            converters=None, skiprows=0, usecols=None, unpack=False,
            ndmin=0, encoding=None, max_rows=None, *, quotechar=None,
            like=None)

Source from the content-addressed store, hash-verified

1118@finalize_array_function_like
1119@set_module('numpy')
1120def loadtxt(fname, dtype=float, comments='#', delimiter=None,
1121 converters=None, skiprows=0, usecols=None, unpack=False,
1122 ndmin=0, encoding=None, max_rows=None, *, quotechar=None,
1123 like=None):
1124 r"""
1125 Load data from a text file.
1126
1127 Parameters
1128 ----------
1129 fname : file, str, pathlib.Path, list of str, generator
1130 File, filename, list, or generator to read. If the filename
1131 extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note
1132 that generators must return bytes or strings. The strings
1133 in a list or produced by a generator are treated as lines.
1134 dtype : data-type, optional
1135 Data-type of the resulting array; default: float. If this is a
1136 structured data-type, the resulting array will be 1-dimensional, and
1137 each row will be interpreted as an element of the array. In this
1138 case, the number of columns used must match the number of fields in
1139 the data-type.
1140 comments : str or sequence of str or None, optional
1141 The characters or list of characters used to indicate the start of a
1142 comment. None implies no comments. For backwards compatibility, byte
1143 strings will be decoded as 'latin1'. The default is '#'.
1144 delimiter : str, optional
1145 The character used to separate the values. For backwards compatibility,
1146 byte strings will be decoded as 'latin1'. The default is whitespace.
1147
1148 .. versionchanged:: 1.23.0
1149 Only single character delimiters are supported. Newline characters
1150 cannot be used as the delimiter.
1151
1152 converters : dict or callable, optional
1153 Converter functions to customize value parsing. If `converters` is
1154 callable, the function is applied to all columns, else it must be a
1155 dict that maps column number to a parser function.
1156 See examples for further details.
1157 Default: None.
1158
1159 .. versionchanged:: 1.23.0
1160 The ability to pass a single callable to be applied to all columns
1161 was added.
1162
1163 skiprows : int, optional
1164 Skip the first `skiprows` lines, including comments; default: 0.
1165 usecols : int or sequence, optional
1166 Which columns to read, with 0 being the first. For example,
1167 ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns.
1168 The default, None, results in all columns being read.
1169 unpack : bool, optional
1170 If True, the returned array is transposed, so that arguments may be
1171 unpacked using ``x, y, z = loadtxt(...)``. When used with a
1172 structured data-type, arrays are returned for each field.
1173 Default is False.
1174 ndmin : int, optional
1175 The returned array will have at least `ndmin` dimensions.
1176 Otherwise mono-dimensional axes will be squeezed.
1177 Legal values: 0 (default), 1 or 2.

Callers

nothing calls this directly

Calls 2

_readFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…