[Numpy-discussion] extension to io.read_array : parse strings

Eric Nodwell nodwell at physics.ubc.ca
Wed May 3 11:44:20 EDT 2006


I've made a small modification to import_array.py so that I can parse
a string as if it were a file.  For example:

>>> B = """# comment line
... 3 4 5
... 2 1 5"""
>>> io.read_array(B, datainstring=1)
array([[ 3.,  4.,  5.],
       [ 2.,  1.,  5.]])

I rather expect that there already exists a standard way to do this,
and if so, I would appreciate it if someone could illustrate. 
Otherwise, if no convenient way of parsing strings into arrays exists
at the moment, and if anyone is of the opinion that this might be
generally useful, then I will submit this as a patch.

(For my own purposes I needed to parse web form input.)

Eric




More information about the NumPy-Discussion mailing list