diff options
-rw-r--r-- | doc/source/user/basics.io.genfromtxt.rst | 22 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 15 |
2 files changed, 19 insertions, 18 deletions
diff --git a/doc/source/user/basics.io.genfromtxt.rst b/doc/source/user/basics.io.genfromtxt.rst index 75ba8a11d..5c0e28e6f 100644 --- a/doc/source/user/basics.io.genfromtxt.rst +++ b/doc/source/user/basics.io.genfromtxt.rst @@ -27,17 +27,19 @@ Defining the input ================== The only mandatory argument of :func:`~numpy.genfromtxt` is the source of -the data. It can be a string corresponding to the name of a local or -remote file, or a file-like object with a :meth:`read` method (such as an -actual file or a :class:`StringIO.StringIO` object), a list of strings, or -a generator. If the argument is the URL of a remote file, then the file -is automatically downloaded to the current directory. - -The input file can be a text file or an archive. Currently, the function +the data. It can be a string, a list of strings, or a generator. If a +single string is provided, it is assumed to be the name of a local or +remote file, or a open file-like object with a :meth:`read` method, for +example, a file or :class:`StringIO.StringIO` object. If a list of strings +or a generator returning strings is provided, each string is treated as one +line in a file. When the URL of a remote file is passed, the file is +automatically downloaded to the current directory and opened. + +Recognized file types are text files and archives. Currently, the function recognizes :class:`gzip` and :class:`bz2` (`bzip2`) archives. The type of -the archive is determined by examining the extension of the file: if the -filename ends with ``'.gz'``, a :class:`gzip` archive is expected; if it -ends with ``'bz2'``, a :class:`bzip2` archive is assumed. +the archive is determined from the extension of the file: if the filename +ends with ``'.gz'``, a :class:`gzip` archive is expected; if it ends with +``'bz2'``, a :class:`bzip2` archive is assumed. diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 9f90039eb..640f4fa32 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1271,12 +1271,11 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, Parameters ---------- - fname : file, str, list of str - File, filename, list, or generator to read. If the filename extension is - `.gz` or `.bz2`, the file is first decompressed. Note that - generators must return byte strings in Python 3k. - The strings in a list or strings produced by a generator are treated - as lines. + fname : file, str, list of str, generator + File, filename, list, or generator to read. If the filename + extension is `.gz` or `.bz2`, the file is first decompressed. Mote + that generators must return byte strings in Python 3k. The strings + in a list or produced by a generator are treated as lines. dtype : dtype, optional Data type of the resulting array. If None, the dtypes will be determined by the contents of each @@ -1457,8 +1456,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, fhd = iter(fname) except TypeError: raise TypeError( - "fname must be a string, filehandle, list of strings, or generator. " - "(got %s instead)" % type(fname)) + "fname must be a string, filehandle, list of strings, " + "or generator. Got %s instead." % type(fname)) split_line = LineSplitter(delimiter=delimiter, comments=comments, autostrip=autostrip)._handyman |