From: Perry G. <pe...@st...> - 2004-04-14 19:10:19
|
Eugeni Doljenko writes: > > John Hunter wrote: > > > Best is to use the binary string operations tostring and fromstring > > > > > > from Numeric import fromstring, Float > > > # write > > > file('fname.out', 'wb').write(x.tostring()) > > > > > > # read > > > x = fromstring(file('fname.out', 'rb').read(), Float) > > > > > > #If data is MxN you'll need to reshape > > > x.shape = M,N > > > > > > Hope this help, > > > JDH > > > > > > > Note that numarray has a tofile method and a fromfile function > > to do this without going through the copying required by tostring > > and fromstring. Like those, it also doesn't save any shape or > Moreover tostring() and fromstring() are deprecated iirc, because you can > convert arrays from and to strings by StringIO. > I just noticed this recently. It isn't the case that tostring and fromstring are deprecated for numarray. I just wanted to clarify. Perry |