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

Function genfromtxt

numpy/lib/_npyio_impl.py:1735–2488  ·  view source on GitHub ↗

Load data from a text file, with missing values handled as specified. Each line past the first `skip_header` lines is split at the `delimiter` character, and characters following the `comments` character are discarded. Parameters ---------- fname : file, str, pathlib.Path,

(fname, dtype=float, comments='#', delimiter=None,
               skip_header=0, skip_footer=0, converters=None,
               missing_values=None, filling_values=None, usecols=None,
               names=None, excludelist=None,
               deletechars=''.join(sorted(NameValidator.defaultdeletechars)),  # noqa: B008
               replace_space='_', autostrip=False, case_sensitive=True,
               defaultfmt="f%i", unpack=None, usemask=False, loose=True,
               invalid_raise=True, max_rows=None, encoding=None,
               *, ndmin=0, like=None)

Source from the content-addressed store, hash-verified

1733@finalize_array_function_like
1734@set_module('numpy')
1735def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
1736 skip_header=0, skip_footer=0, converters=None,
1737 missing_values=None, filling_values=None, usecols=None,
1738 names=None, excludelist=None,
1739 deletechars=''.join(sorted(NameValidator.defaultdeletechars)), # noqa: B008
1740 replace_space='_', autostrip=False, case_sensitive=True,
1741 defaultfmt="f%i", unpack=None, usemask=False, loose=True,
1742 invalid_raise=True, max_rows=None, encoding=None,
1743 *, ndmin=0, like=None):
1744 """
1745 Load data from a text file, with missing values handled as specified.
1746
1747 Each line past the first `skip_header` lines is split at the `delimiter`
1748 character, and characters following the `comments` character are discarded.
1749
1750 Parameters
1751 ----------
1752 fname : file, str, pathlib.Path, list of str, generator
1753 File, filename, list, or generator to read. If the filename
1754 extension is ``.gz`` or ``.bz2``, the file is first decompressed. Note
1755 that generators must return bytes or strings. The strings
1756 in a list or produced by a generator are treated as lines.
1757 dtype : dtype, optional
1758 Data type of the resulting array.
1759 If a structured dtype, the output array will be 1D and structured where
1760 each field corresponds to one column.
1761 If None, the dtype of each column will be inferred automatically, and
1762 the output array will be structured only if either the dtypes are not
1763 all the same or if `names` is not None.
1764 comments : str, optional
1765 The character used to indicate the start of a comment.
1766 All the characters occurring on a line after a comment are discarded.
1767 delimiter : str, int, or sequence, optional
1768 The string used to separate values. By default, any consecutive
1769 whitespaces act as delimiter. An integer or sequence of integers
1770 can also be provided as width(s) of each field.
1771 skiprows : int, optional
1772 `skiprows` was removed in numpy 1.10. Please use `skip_header` instead.
1773 skip_header : int, optional
1774 The number of lines to skip at the beginning of the file.
1775 skip_footer : int, optional
1776 The number of lines to skip at the end of the file.
1777 converters : variable, optional
1778 The set of functions that convert the data of a column to a value.
1779 The converters can also be used to provide a default value
1780 for missing data: ``converters = {3: lambda s: float(s or 0)}``.
1781 missing : variable, optional
1782 `missing` was removed in numpy 1.10. Please use `missing_values`
1783 instead.
1784 missing_values : variable, optional
1785 The set of strings corresponding to missing data.
1786 filling_values : variable, optional
1787 The set of values to be used as default when the data are missing.
1788 usecols : sequence, optional
1789 Which columns to read, with 0 being the first. For example,
1790 ``usecols = (1, 4, 5)`` will extract the 2nd, 5th and 6th columns.
1791 names : {None, True, str, sequence}, optional
1792 If `names` is True, the output will be a structured array whose field

Callers

nothing calls this directly

Calls 15

make_mask_descrFunction · 0.90
LineSplitterClass · 0.85
NameValidatorClass · 0.85
_decode_lineFunction · 0.85
_is_string_likeFunction · 0.85
easy_dtypeFunction · 0.85
StringConverterClass · 0.85
flatten_dtypeFunction · 0.85
ConverterErrorClass · 0.85
encode_unicode_colsFunction · 0.85
has_nested_fieldsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…