Prev Up Next Index
Go backward to 9.3 readfile
Go up to 9 Format Conversion
Go forward to 9.4.1 Simple ASCII to Binary Conversion

9.4 Creating a Binary Archive

 

By storing data files in binary, you save disk space and make access by applications more efficient. An ASCII data file can take two to five times the disk space of a comparable binary data file. Not only is there less information in each byte, but extra bytes are needed for decimal points, delimiters, and end-of-line markers.

It is very easy to create a binary archive using newform as the following examples show. The input data for these examples are in the ASCII file latlon.dat (shown below). They consist of 20 random latitude and longitude values. The size of the file on a Unix system is 460 bytes.

Here is the latlon.dat file:

-47.303545 -176.161101
 -0.928001    0.777265
-28.286662   35.591879
 12.588231  149.408117
-83.223548   55.319598
 54.118314 -136.940570
 38.818812   91.411330
-34.577065   30.172129
 27.331551 -155.233735
 11.624981 -113.660611
 77.652742  -79.177679
 77.883119  -77.505502
-65.864879  -55.441896
-63.211962  134.124014
 35.130219 -153.543091
 29.918847  144.804390
-69.273601   38.875778
-63.002874   36.356024
 35.086084  -21.643402
-12.966961   62.152266

Tom Sgouros and James Gallagher, 2006-02-12

Prev Up Next