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

Function genfromtxt

numpy/lib/npyio.py:1744–2474  ·  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)),
               replace_space='_', autostrip=False, case_sensitive=True,
               defaultfmt="f%i", unpack=None, usemask=False, loose=True,
               invalid_raise=True, max_rows=None, encoding='bytes',
               *, ndmin=0, like=None)

Source from the content-addressed store, hash-verified

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

Callers 2

recfromtxtFunction · 0.85
recfromcsvFunction · 0.85

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