Introduction to GPSBabel Styles

Often it is desirable to add a new file format for "one-off" work (perhaps you want to export something to a spreadsheet or graphing program) or to read a format that GPSBabel does not yet support. For suitably simple formats, this can be done by a user with no programming experience by providing a GPSBabel style file.

For a format to be described by a style file, it must be predictable and generally readable by humant. Formats with binary or unreadable content are not good fits for this scheme. It should have:

A fixed header at the beginning, if it has any at all. This is called a 'prologue'.
Waypoints that are grouped by fixed separators, often a newline. In style file parlance, this is called a 'record'.
Traits of that waypoint described in that record. In the style files, these are called 'fields' and examples may include longitude or a name.
Fields that are grouped by fixed separators, often a comma or a tab. In the style files, this is called the field separator. Fields may be enclosed by characters, such as a double quote.
A fixed footer at the end, if it has any at all. This is called the 'epilogue'.

Once you have created a style file that describes the file format you have or want, you must tell GPSBabel to use the xcsv format and have the xcsv format use that file. If you created a new style file called "mystyle.style" and you want to write the waypoints from a GPX file named "mine.gpx" to it, you would issue a command like:

gpsbabel -i gpx -f mine.gpx -o xcsv,style=mystyle.style -F mine.new

You might then examine mine.new to see if it met your expectations. If not, you could continue to tweak mystyle.style until it did, rerunning the above command each time. If 'mystyle' is a format that describes a popular program or is likely to be of use to others, you can then share mystyle.style with other GPSBabel users. Send it along with a coherent description to the GPSBabel-Misc mailing list for consideration to be included in a future version.