diff options
author | Leonardo Donelli <learts92@gmail.com> | 2014-10-05 16:27:02 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-01-23 09:10:11 -0700 |
commit | 95aac05724290159044aecf443df1b95e218e895 (patch) | |
tree | 751efe2478bf152c09c240122a6fa718f7c55b69 /numpy/lib/npyio.py | |
parent | 5b714c7ecd46ed8e730afc8f37f8b8d1faf36497 (diff) | |
download | numpy-95aac05724290159044aecf443df1b95e218e895.tar.gz |
BUG: Fix loadtxt with comments=None and a string None data.
Current loadtxt with `comments=None` considers the string `'None'` as a
comment symbol. Fixed by making split_line method check if comments is
None.
Closes #5155.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index bedd0e941..a40de4fea 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -729,7 +729,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, """ # Type conversions for Py3 convenience - comments = asbytes(comments) + if comments is not None: + comments = asbytes(comments) user_converters = converters if delimiter is not None: delimiter = asbytes(delimiter) @@ -802,7 +803,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, def split_line(line): """Chop off comments, strip, and split at delimiter.""" - line = asbytes(line).split(comments)[0].strip(asbytes('\r\n')) + if comments is None: + line = asbytes(line).strip(asbytes('\r\n')) + else: + line = asbytes(line).split(comments)[0].strip(asbytes('\r\n')) if line: return line.split(delimiter) else: |