MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Binary data files

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Binary data files
  • From: TODD GAYLEY <TGAYLEY at ccit.arizona.edu>
  • Date: Thu, 13 Aug 1992 12:26 MST

Kerry Ryan (kerry at nucleus.immunol.washington.edu) asks:

>   I am analyzing binary data files with Mathematica and would 
>   like to write a new binary data file with the processed data. 
>   Mathematica reads binary data just fine using 
>   ReadList["filename",Byte], however, I can't find a way to 
>   write the processed data back to a binary file.  I have torn the 
>   book apart looking for a way ... any suggestions?

It is my understanding that Mm 2.1 will have capabilities for 
dealing with binary files built-in. Until then, if you are using 
Macintosh, the following function works (I don't know about 
other platforms, except that it definitely doesn't work under DOS 
or Windows). It takes a list of numerical values in the range 
0..255 and writes them out as single bytes:

WriteBytes[list_List, filename_String] :=
   ( OpenWrite[filename, FormatType->TextForm, PageWidth->Infinity];
     WriteString[filename, FromCharacterCode[list]];
     Close[filename];
   )

--Todd Gayley
--University of Arizona





  • Prev by Date: Re: graphics 3D
  • Next by Date: Re: timing of Table operation - a functional form
  • Previous by thread: Binary data files
  • Next by thread: Binary data files