Headers and data records in dBASE format are represented in ASCII but
are not separated by end-of-line characters. They can be difficult to
read or to use in applications that expect newlines to separate
records. By using newform, dBASE data can be reformatted to
include end-of-line characters.
In this example, you will reformat the dBASE data file
oceantmp.dab (see below) into the ASCII data file
oceantmp.dat. The input file oceantmp.dab contains a
record header at the beginning of each line. The header is followed by
data on the same line. When you convert the file to ASCII, the header
will be on one line followed by the data on the number of lines
specified by the variable count. The format description file
oceantmp.fmt is used for this reformatting.
Here is oceantmp.fmt:
dbase_record_header "NODC-01 record header format" WMO_quad 1 1 char 0 latitude_deg_abs 2 3 uchar 0 latitude_min 4 5 uchar 0 longitude_deg_abs 6 8 uchar 0 longitude_min 9 10 uchar 0 date_yymmdd 11 16 long 0 hours 17 19 uchar 1 country_code 20 21 char 0 vessel 22 23 char 0 count 24 26 short 0 data_type_code 27 27 char 0 cruise 28 32 long 0 station 33 36 short 0 dbase_data "IBT input format" depth_m 1 4 short 0 temperature 5 8 short 2 RETURN "NEW LINE INDICATOR" ASCII_data "ASCII output format" depth_m 1 5 short 0 temperature 27 31 float 2
This format description file contains a header format description, a
description for dBASE input data, the special RETURN descriptor, and a
description for ASCII output data. The variable count (fourth
from the bottom in the header format description) indicates the number
of data records that follow each header. The descriptor RETURN lets
newform skip over the end-of-line marker at the end of each data
block in the input file oceantmp.dab as it is meaningless to
newform here. Because the end-of-line marker appears at the end
of the data records in each input data block, RETURN is placed after
the input data format description in the format description file.
oceantmp.dab:
1 2 3 4 5 6 7
1234567890123456789012345678901234567890123456789012345678901234567890
11000171108603131109998 4686021000000002767001027670020276700302767
110011751986072005690AM 4686091000000002928001028780020287200302872
11111176458102121909998 4681011000000002728009126890241110005000728
112281795780051918090PI 268101100000000268900402711
Each dBASE header in oceantmp.dab is located from position 1 to
36. It is followed by four data records of 8 bytes each. Each record
comprises a depth and temperature reading. The variable count in the
header (positions 24-26) indicates that there are 4 data records each
in the first 3 lines and 2 on the last line. This will all be more
obvious after conversion.
To reformat oceantmp.dab to ASCII, use the following command:
newform oceantmp.dab -o oceantmp.dat
The resulting file oceantmp.dat is much easier to read. It is
readily apparent that there are 4 data records after the first three
headers and 2 after the last.
Here is oceantmp.dat:
1 2 3 4
1234567890123456789012345678901234567890
11000171108603131109998 46860210000
0 27.67
10 27.67
20 27.67
30 27.67
110011751986072005690AM 46860910000
0 29.28
10 28.78
20 28.72
30 28.72
11111176458102121909998 46810110000
0 27.28
91 26.89
241 11.00
500 07.28
112281795780051918090PI 26810110000
0 26.89
40 27.11