From ce75d262b5b67c03d972e14d7c7f1d24ffea5e68 Mon Sep 17 00:00:00 2001 From: dhuard Date: Fri, 5 Sep 2008 13:58:00 +0000 Subject: Applied patch from R. May fixing ticket #905 (loadtxt). Fixed other bug occurring when both usecols and converters are provided. Added related regression tests. --- numpy/lib/io.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'numpy/lib/io.py') diff --git a/numpy/lib/io.py b/numpy/lib/io.py index 41ffc51b8..5348866c4 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -312,7 +312,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, """ user_converters = converters - + + if usecols is not None: + usecols = list(usecols) + if _string_like(fname): if fname.endswith('.gz'): import gzip @@ -373,7 +376,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None, # By preference, use the converters specified by the user for i, conv in (user_converters or {}).iteritems(): if usecols: - i = usecols.find(i) + i = usecols.index(i) converters[i] = conv # Parse each line, including the first -- cgit v1.2.1