Reading Binary Files
- To: mathgroup at smc.vnet.net
- Subject: [mg5171] Reading Binary Files
- From: biblblak at ozemail.com.au (bibleBlack)
- Date: Wed, 6 Nov 1996 01:34:46 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I have to read data from binary
files for analysis. Each record in the file has the following
format according to the
manufacturer (Davis in the states) of the anenometer:
short packedTime; // Time of archive. 0...1440 minutes.
short hiOutsideTemperature; // High outside temperature in the
interval.
short lowOutsideTemperature; // Low outside temperature in the interval.
short insideTemperature; // Average inside temperature in the
interval.
short outsideTemperature; // Average outside temperature in the
interval.
short barometer; // Barometer at the time of the archive.
unsigned char insideHumidity; // Inside humidity at the time of the
archive.
unsigned char outsideHumidity; // Outside humidity at the time of the
archive.
short dewPoint; // Derived from outside humidty and
outside t.
unsigned short rain; // Rain clicks in the interval.
unsigned char windSpeed; // Average wind speed in the interval.
unsigned char hiWindSpeed; // High wind speed in the interval.
short windChill; // Derived from wind speed and outside
temperature.
unsigned char windDirection; // Dominant wind direction in the interval
unsigned char archiveInterval; // Interval between archive entrys.
A "short" is two bytes long.
A "unsigned char" is one byte long.
I have tried to open the file as an input stream, and read record by
record of byte -
and get uneven length lists of integers between 0 and 255. Does anyone know
how to make Mathematica read a file of this type so that the result is
something like:
{
{
time, (* integer in minutes *),
windSpeed, (* integer in miles/hour *)
archiveInterval (* integer in minutes *)
},
{
...,
...,
...
},
...
}
Thanks All,
andy.white at rmit.edu.au