next up previous contents index
Next: Data specifications Up: Preparing Input for plt Previous: Comma-separated value (CSV) files

Binary data files

plt can also read some types of binary data files. You can create files of these types by writing the data as a sequence of short integer, float, or double format numbers. These types may not be mixed in a single data file. The sizes of these data types and their byte ordering rules are architecture-dependent, so that binary data files, unlike text data files, are not necessarily portable between computers of different types.

The structure of binary data files is similar to that of text data files, in that data are (conceptually) organized in rows and columns. If your file contains values for $N$ variables (columns), each row must contain $N$ values, one for each column. The data file does not contain any row boundary markers; you must specify the number of columns and the data type using either an embedded two-byte descriptive header at the beginning of the data file, or an appropriate data specification on the plt command line, so that the input can be parsed correctly.

A binary data file can be most easily used by plt if its first two bytes describe its format. To do this, the first byte should contain the number of bytes per data value (on most current CPUs, this is 2 for short, 4 for float, or 8 for double values), and the second byte should contain the number of columns per row. These header bytes should be followed immediately by the data. plt can recognize binary files of this type because text files should contain printing characters and whitespace only (the byte values 2, 4, and 8 correspond to non-printing, non-whitespace control characters).

The two-byte header is optional. If it is omitted, however, you must use a data specification (see the next section) in order to advise plt of the format of your data. Binary data files to be used as input to plt should not contain any information other than the optional header and the data themselves, although it is possible to skip over an embedded prolog or epilog in most cases.


next up previous contents index
Next: Data specifications Up: Preparing Input for plt Previous: Comma-separated value (CSV) files
George B. Moody (george@mit.edu)
2005-04-26