GURGLE Tutorial: Basic Definition File

Included below is a basic definition file to process our phone directory database. Copy it into a file in the same directory as the data source file and call it phones1.grg or directly download and save phones1.grg.

%%database "phonedir.txt"
%%define DELIM |
%%define NAMCOL

The file contains three lines. The first specifies the database source to use. The second defines the field delimiter (this line would have been unneccessary if we had used a whitespace delimited input file). The third means that the first line of the database file should be interpreted as containing the field names.

Now we need to gurgle the above file to produce the output.

gurgle phones1.grg

If everything worked this will created phones1.tex which is the output file which should look like below.

FIRSTNAME|LASTNAME|EXTENSION|ROOM|JOB
Joe|Bloggs|4455|C99|Manager
Jack|Frost|4321|A23|Air Conditioning Technician
John|Doe|3888|B56|Coroner
Mike|Tyson|7911|A23|Security
Rosanne|Barr|1111|A01|Receptionist
Bill|Clinton|4723|C55|Legal Services
Jerry|Springer|8844|B44|Public Relations
Frasier|Crane|6542|B78|Counsellor

Well we haven't gained much there! The default behaviour of gurgle includes a default header (taken from the names of the fields) and a default record which is just the values using the delimiter specified in the definition file. So our output in this case is identical to our input.

Exercises

Try the definition file without the NAMCOL and the DELIM directive lines and observe the different behaviour. A definition file must always have at least one database line otherwise there will be an error.

Now lets actually format the output.

NEXT