Re: Binary file I/O
- Subject: [mg2960] Re: Binary file I/O
- From: ianc (Ian Collier)
- Date: 17 Jan 1996 05:19:21 -0600
- Approved: usenet@wri.com
- Distribution: local
- Newsgroups: wri.mathgroup
- Organization: Wolfram Research, Inc.
- Sender: mj at wri.com
In article <4dd2qp$al at dragonfly.wri.com>, Matt Reed <mreed at umich.edu> wrote: > I am working with large datasets that I would prefer to store as binary > data rather than ASCII. These files could be, for example, single- or > double-precision numbers. What is the most efficient way of handling > input and output of such datafiles in Mma? I've considered writing an > external translator to read the data and pipe it to Mma in ASCII, but I > wonder if it is possible to access binary data in a file directly. > > Matt Reed > University of Michigan You could try using Utilities`BinaryFiles`, one of the Standard Mathematica Packages included in the Mathematica distribution. It is documented on pages 403-409 of the Guide to Standard Mathematica Packages Technical Report. You might also want to look at FastBinaryFiles on MathSource: 0206-783: FastBinaryFiles: A MathLink Program for Fast Reading and Writing of Binary Files Todd Gayley FastBinaryFiles is a MathLink program and Mathematica package for fast reading and writing of binary files. It is intended as a replacement for the standard package Utilities`BinaryFiles`, which is slow and cannot be used under MS Windows. A ready-to-run executable is available for Mac and Windows; others will have to build the program from the single source file, binary.tm. Note that there is no separate package (.m) file. If you want to use the program on Mac or Windows, the executable is all you need. If you want to compile it on your own, the C source file binary.tm is all you need. You need Mathematica version 2.2 or later to use FastBinaryFiles (I haven't tried it with v2.1, but it might work). DOS users cannot use it, as MathLink is not available for DOS, and Windows users need either version 2.2.2, or 2.2.1 and the MathLink Developer's Kit for Windows. This program is discussed more fully in Volume 4, Issue 2 of The Mathematica Journal. README.txt (7 Kb) binary.tm (83 Kb) binary.zip (38 Kb) binary.sit.hqx (119 Kb) I hope this helps. --Ian ----------------------------------------------------------- Ian Collier Technical Sales Support Wolfram Research, Inc. ----------------------------------------------------------- tel:(217) 398-0700 fax:(217) 398-0747 ianc at wri.com Wolfram Research Home Page: http://www.wri.com/ -----------------------------------------------------------