summaryrefslogtreecommitdiff
path: root/numpy/lib/io.py
diff options
context:
space:
mode:
authordhuard <dhuard@localhost>2008-09-05 13:58:00 +0000
committerdhuard <dhuard@localhost>2008-09-05 13:58:00 +0000
commitce75d262b5b67c03d972e14d7c7f1d24ffea5e68 (patch)
tree6d162df1abf0eedeb6e002cc4aac391ce7e5bd41 /numpy/lib/io.py
parentbcaa1793226b8dab929d8ccc786c23854f5886e0 (diff)
downloadnumpy-ce75d262b5b67c03d972e14d7c7f1d24ffea5e68.tar.gz
Applied patch from R. May fixing ticket #905 (loadtxt). Fixed other bug occurring when both usecols and converters are provided. Added related regression tests.
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r--numpy/lib/io.py7
1 files changed, 5 insertions, 2 deletions
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