From: Konrad H. <hi...@cn...> - 2000-12-12 18:21:10
|
> I'm trying to find out what format a matrix input file should have in > numpy. Any format you like, but you have to supply the I/O code yourself. Which however is really simple. For example, the following function from ScientificPython: from Scientific.IO.TextFile import TextFile import string, Numeric def readArray(filename): "Return an array containing the data from file |filename|." data = [] for line in TextFile(filename): if line[0] != '#': data.append(map(eval, string.split(line))) a = Numeric.array(data) if a.shape[0] == 1 or a.shape[1] == 1: a = Numeric.ravel(a) return a Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- |