Prev Up Next Index
Go backward to 9.4.7 Reading the Binary File
Go up to 9.4 Creating a Binary Archive
Go forward to 9.5 File Names and Context

9.4.8 Including a Query

You can use the query option (-q query_file) to specify exactly which records in the data file newform should process. The query file contains query criteria. Query syntax is summarized in Appendix C.

In this example, you will specify a query so that newform will reformat only those value pairs in latlon.dat where latitude is positive and longitude is negative into the binary file llposneg.bin. The input and output data formats are described in latlon2.fmt.

The query criteria are specified in the following file, called llposneg.qry:

[latitude] > 0 & [longitude] < 0 

To convert the desired data in latlon.dat to binary and then view the results:

  1. Enter the following command:
    newform latlon.dat -f latlon2.fmt -q llposneg.qry  
           -o llposneg.bin 
    
    The llposneg.bin file now contains the positive/negative latitude/longitude pairs in binary form.
  2. To view the data, first convert the data in llposneg.bin back to ASCII format: newform llposneg.bin -f latlon2.fmt -o llposneg.dat
  3. Enter the appropriate command to display the data in llposneg.dat, e.g. more: The following output appears on the screen:
    54.118314 -136.940570
    27.331551 -155.233735
    11.624981 -113.660611
    77.652742  -79.177679
    77.883119  -77.505502
    35.130219 -153.543091
    35.086084  -21.643402
    

    NOTE: As demonstrated in the examples above, you can check the data in a binary file either by using readfile or by converting the data back to ASCII using newform and then viewing it.


Tom Sgouros and James Gallagher, 2006-02-12

Prev Up Next