Reading Binary Data

Data is sometimes stored in files as arrays of bytes instead of a known format like JPEG or TIFF. These files are referred to as binary files. Binary data or binary data files are more compact than ASCII data files and are frequently used for large data files. Binary data files are stored as one long stream of bytes in a file. You will need to define the structure of the fields in the file in order to correctly read in the binary data.

The BINARY_TEMPLATE and READ_BINARY functions are designed to define and access binary data. The READ_BINARY function, which reads binary data, is either invoked internally (when you open a binary file from the iTools), or is explicitly called from the command line. This function is intended to read raw binary data that requires no special processing (except possibly byte-order swapping). This function is not designed to read commercial spreadsheet or word processing files.

Note
If you prefer not to use an interactive Binary Template dialog (described below) to define the structure of the data in the binary file, you can use the READU procedure. To read binary data files, define the variables, open the file for reading, and read the bytes into those variables. Each variable reads as many bytes out of the file as required by the specified data type and organizational structure.

If you need to open a single binary file, it may be easier to use READ_BINARY to directly define data characteristics using keywords instead of creating a template using the Binary Template dialog (described below). See "READ_BINARY" (IDL Reference Guide) for an example.

Launching the Binary Template Dialog

The BINARY_TEMPLATE function launches a dialog that you can use to define the structure of data in an binary file. Access this feature in one of the following ways:

Note
If you specify a Filename argument to BINARY_TEMPLATE, the dialog allowing you to browse to select a file will not appear. See "BINARY_TEMPLATE" (IDL Reference Guide) if you want specify a file and other parameters programmatically.

See Using the BINARY_TEMPLATE Interface under "BINARY_TEMPLATE" (IDL Reference Guide) for instructions on how to use the dialog to define the structure of your binary file.