[PYTHON MATRIX-SIG] Data i/o and Numeric module

Konrad Hinsen hinsen@ibs.ibs.fr
Tue, 10 Dec 96 11:01:13 +0100


> I've read the documentation and can't see a way to load data directly 
> from a file into a Numeric array. I am guessing that if you have a lot
> of data ( 2000 * 2000 points say ) then it would be better not to incur
> the overhead of loading the data into a Numeric array via a Python list. 

Indeed.

> The data I need to access is currently either in Fortran binary files or
> flat ASCII files. 

I can offer:

1) A Python module that reads ASCII files with numbers into arrays.
   Slow, but it works.

2) A C module that reads Fortran binary files, with some restrictions:
   a) It reads one record into one array (one data type). That doesn't
      work with records that contain, for example, both integers and
      reals.
   b) It may not be portable, since the layout of Fortran binary files
      is compiler dependent. My module uses the layout used by all
      Unix compilers I know of, but probably it won't work on non-Unix
      systems.
   On the plus side, it is as fast as it could possibly be; it reads
   a whole record into one array with one read statement.

Ultimately someone will have to do a fast (i.e. C) module for ASCII I/O
of arrays...
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================