diff options
author | pierregm <pierregm@localhost> | 2009-10-16 03:10:49 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-10-16 03:10:49 +0000 |
commit | e8f48653c396a1ae2e838cc1f463d5c32cf1d6fa (patch) | |
tree | f6b3994e5e3a06de53114945c3812a06c5ef4f18 /numpy/lib/io.py | |
parent | 2251993805670563e641cfcc420de302930ba190 (diff) | |
download | numpy-e8f48653c396a1ae2e838cc1f463d5c32cf1d6fa.tar.gz |
* io.genfromtxt
- `usecols` can now be a comma-separated string
- make sure that an explicit name list shorter than an explicit dtype is properly expanded
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r-- | numpy/lib/io.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py index da3296ae4..cb8c63666 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -1069,9 +1069,12 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Check the columns to use if usecols is not None: try: - usecols = list(usecols) - except TypeError: - usecols = [usecols,] + usecols = [_.strip() for _ in usecols.split(",")] + except AttributeError: + try: + usecols = list(usecols) + except TypeError: + usecols = [usecols,] nbcols = len(usecols or first_values) # Check the names and overwrite the dtype.names if needed @@ -1087,7 +1090,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, # Get the dtype if dtype is not None: dtype = easy_dtype(dtype, defaultfmt=defaultfmt, names=names) - + names = dtype.names if usecols: for (i, current) in enumerate(usecols): |