MCPcopy Create free account
hub / github.com/numpy/numpy / loadtxt

Function loadtxt

numpy/lib/npyio.py:1100–1378  ·  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='bytes', max_rows=None, *, quotechar=None,
            like=None)

Source from the content-addressed store, hash-verified

1098@set_array_function_like_doc
1099@set_module('numpy')
1100def loadtxt(fname, dtype=float, comments='#', delimiter=None,
1101 converters=None, skiprows=0, usecols=None, unpack=False,
1102 ndmin=0, encoding='bytes', max_rows=None, *, quotechar=None,
1103 like=None):
1104 r"""
1105 Load data from a text file.
1106
1107 Parameters
1108 ----------
1109 fname : file, str, pathlib.Path, list of str, generator
1110 File, filename, list, or generator to read. If the filename
1111 extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note
1112 that generators must return bytes or strings. The strings
1113 in a list or produced by a generator are treated as lines.
1114 dtype : data-type, optional
1115 Data-type of the resulting array; default: float. If this is a
1116 structured data-type, the resulting array will be 1-dimensional, and
1117 each row will be interpreted as an element of the array. In this
1118 case, the number of columns used must match the number of fields in
1119 the data-type.
1120 comments : str or sequence of str or None, optional
1121 The characters or list of characters used to indicate the start of a
1122 comment. None implies no comments. For backwards compatibility, byte
1123 strings will be decoded as 'latin1'. The default is '#'.
1124 delimiter : str, optional
1125 The character used to separate the values. For backwards compatibility,
1126 byte strings will be decoded as 'latin1'. The default is whitespace.
1127
1128 .. versionchanged:: 1.23.0
1129 Only single character delimiters are supported. Newline characters
1130 cannot be used as the delimiter.
1131
1132 converters : dict or callable, optional
1133 Converter functions to customize value parsing. If `converters` is
1134 callable, the function is applied to all columns, else it must be a
1135 dict that maps column number to a parser function.
1136 See examples for further details.
1137 Default: None.
1138
1139 .. versionchanged:: 1.23.0
1140 The ability to pass a single callable to be applied to all columns
1141 was added.
1142
1143 skiprows : int, optional
1144 Skip the first `skiprows` lines, including comments; default: 0.
1145 usecols : int or sequence, optional
1146 Which columns to read, with 0 being the first. For example,
1147 ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns.
1148 The default, None, results in all columns being read.
1149
1150 .. versionchanged:: 1.11.0
1151 When a single column has to be read it is possible to use
1152 an integer instead of a tuple. E.g ``usecols = 3`` reads the
1153 fourth column the same way as ``usecols = (3,)`` would.
1154 unpack : bool, optional
1155 If True, the returned array is transposed, so that arguments may be
1156 unpacked using ``x, y, z = loadtxt(...)``. When used with a
1157 structured data-type, arrays are returned for each field.

Callers

nothing calls this directly

Calls 2

_readFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected