r""" Read a NumPy array from a text file. This is a helper function for loadtxt. Parameters ---------- fname : file, str, or pathlib.Path The filename or the file to be read. delimiter : str, optional Field delimiter of the fields in line of the file.
(fname, *, delimiter=',', comment='#', quote='"',
imaginary_unit='j', usecols=None, skiplines=0,
max_rows=None, converters=None, ndmin=None, unpack=False,
dtype=np.float64, encoding=None)
| 859 | |
| 860 | |
| 861 | def _read(fname, *, delimiter=',', comment='#', quote='"', |
| 862 | imaginary_unit='j', usecols=None, skiplines=0, |
| 863 | max_rows=None, converters=None, ndmin=None, unpack=False, |
| 864 | dtype=np.float64, encoding=None): |
| 865 | r""" |
| 866 | Read a NumPy array from a text file. |
| 867 | This is a helper function for loadtxt. |
| 868 | |
| 869 | Parameters |
| 870 | ---------- |
| 871 | fname : file, str, or pathlib.Path |
| 872 | The filename or the file to be read. |
| 873 | delimiter : str, optional |
| 874 | Field delimiter of the fields in line of the file. |
| 875 | Default is a comma, ','. If None any sequence of whitespace is |
| 876 | considered a delimiter. |
| 877 | comment : str or sequence of str or None, optional |
| 878 | Character that begins a comment. All text from the comment |
| 879 | character to the end of the line is ignored. |
| 880 | Multiple comments or multiple-character comment strings are supported, |
| 881 | but may be slower and `quote` must be empty if used. |
| 882 | Use None to disable all use of comments. |
| 883 | quote : str or None, optional |
| 884 | Character that is used to quote string fields. Default is '"' |
| 885 | (a double quote). Use None to disable quote support. |
| 886 | imaginary_unit : str, optional |
| 887 | Character that represent the imaginary unit `sqrt(-1)`. |
| 888 | Default is 'j'. |
| 889 | usecols : array_like, optional |
| 890 | A one-dimensional array of integer column numbers. These are the |
| 891 | columns from the file to be included in the array. If this value |
| 892 | is not given, all the columns are used. |
| 893 | skiplines : int, optional |
| 894 | Number of lines to skip before interpreting the data in the file. |
| 895 | max_rows : int, optional |
| 896 | Maximum number of rows of data to read. Default is to read the |
| 897 | entire file. |
| 898 | converters : dict or callable, optional |
| 899 | A function to parse all columns strings into the desired value, or |
| 900 | a dictionary mapping column number to a parser function. |
| 901 | E.g. if column 0 is a date string: ``converters = {0: datestr2num}``. |
| 902 | Converters can also be used to provide a default value for missing |
| 903 | data, e.g. ``converters = lambda s: float(s.strip() or 0)`` will |
| 904 | convert empty fields to 0. |
| 905 | Default: None |
| 906 | ndmin : int, optional |
| 907 | Minimum dimension of the array returned. |
| 908 | Allowed values are 0, 1 or 2. Default is 0. |
| 909 | unpack : bool, optional |
| 910 | If True, the returned array is transposed, so that arguments may be |
| 911 | unpacked using ``x, y, z = read(...)``. When used with a structured |
| 912 | data-type, arrays are returned for each field. Default is False. |
| 913 | dtype : numpy data type |
| 914 | A NumPy dtype instance, can be a structured dtype to map to the |
| 915 | columns of the file. |
| 916 | encoding : str, optional |
| 917 | Encoding used to decode the inputfile. The special value 'bytes' |
| 918 | (the default) enables backwards-compatible behavior for `converters`, |
no test coverage detected
searching dependent graphs…