|
From: Eugeni D. <dol...@rs...> - 2004-04-09 08:25:36
|
----- Original Message -----
From: "Perry Greenfield" <pe...@st...>
To: "John Hunter" <jdh...@ni...>; "Randy Heiland"
<he...@in...>
Cc: <mat...@li...>
Sent: Thursday, April 08, 2004 10:47 PM
Subject: RE: [Matplotlib-users] writing binary array to file
> 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.
> type info in the file.
>
> Perry
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|