NumPY: Reading/Writing Arrays To/From Files

John J. Lee phrxy at csv.warwick.ac.uk
Thu Mar 29 13:18:32 EST 2001


On Wed, 28 Mar 2001, Grant Griffin wrote:

> Ben Held wrote:
> >
> > I would like to be able to read/write NumPY array objects to/from ascii
> > files.  I could not find support for this in the NumPY code.  Any ideas?
> >
> > Ben
>
> I forget exactly, but I think there's something out there called
> "arrayio".  Look for Travis Oliphant's page: I think you can find it
> there.
[...]

ArrayIO I think is for binary data, not ASCII.  As far as I can tell,
Travis' pages haven't resurfaced since they disappeared a few months ago.
There is a copy at

http://starship.python.net/~da/Travis/numpyio/

but this may be ancient for all I know.  You can do the same thing with
the Python standard library too, IIRC.

TableIO reads ASCII tables.

http://php.iupui.edu/~mmiller3/python/

There is a bug somewhere around line 40 that you'll get if you use Numeric
arrays where it wants lists.  Just delete the line that checks for array
type, and put in a try / except if you feel like it.

This is faster than a python version of course, but the GNU C library
implementation of strtok() has trouble with input like .3 or 3. (one or
the other).


John




More information about the Python-list mailing list