[SciPy-user] Fwd: io.read_array and columns of strings

Eric Nodwell nodwell at physics.ubc.ca
Mon Feb 20 11:29:21 CST 2006


Hi,

I notice that io.read_array (scipy version 0.4.4, numpy version 0.9.4)
does not seem to support reading a column of strings.  For example:

>>> A = io.read_array ('r1683.log.layers', atype=[(string,10), Float])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/sw/lib/python2.4/site-packages/scipy/io/array_import.py",
line 358, in read_array
    if not atype[k] in typecodes:
TypeError: 'in <string>' requires string as left operand

Perhaps this is intended behaviour, although standard numpy arrays do
support string types, for example

A = array (('one', 'two'), (string,10))

Of course, it's easy to work around this by reading the data with a
loop instead of read_array.  So this is "wish-list" kind of item for
convenience and consistency.  Any thoughts?

thanks,
Eric



More information about the SciPy-user mailing list