Jump to content

Gpsbabel Csv Style Sheets


byonke

Recommended Posts

Gpsbabel is more and more becoming my main program for waypoint conversion, but now I would like more control of the CSV data output. I am at a loss when trying to understand the use of style sheets. Are these sheets external to the executable and can they be modified by the end user. Any help or direction would be greatly appreciated.

 

Thanks

Brian

Link to comment

Are these sheets external to the executable and can they be modified by the end user.

 

To answer both questions at once, yes. The style sheets are compiled into the executable at compile time and show up in the formats listing (gpsbabel -h). They can also be used externally at runtime via the "xcsv" input/output format.

 

For example, in the gpsbabel source code tree there is a directory off the main program called "style". In this folder you'll find several files, including a "README.style" that explains what each style option does. The other files (*.style) are pre-defined csv style sheets that get compiled into the main program when it is created.

 

The easiest way to make your own is to make a copy of one of these, modify it to your liking, and use it from the command line (if you don't have the resources to compile GPSBabel from source code yourself).

 

For example, if you wanted a format similar to the MS Streets & Trips CSV format, but with a field for altitude, you'd do something like this:

 

# gpsbabel XCSV style file
#
# Format: MS S&T 2002/2003
# Author: Alex Mottram
#   Date: 12/09/2002
#
# 
# As requested by Noel Shrum on the gpsbabel-code mailing list.
# Name,Latitude,Longitude,Name 2,URL,Type
# GCCBF,44.479133,-85.56515,High Rollaway by rjlint,http://www.geocaching.com/seek/cache_details.aspx?ID=3263,Traditional Cache
# GC110D,44.6522,-85.492483,Brown Bridge Pond Peek-a-Boo Cache by Big Bird,http://www.geocaching.com/seek/cache_details.aspx?ID=4365,Traditional Cache
# GC171C,44.70605,-85.62265,The Michigan Frog by RealDcoy & LRB,http://www.geocaching.com/seek/cache_details.aspx?ID=5916,Traditional Cache
#

DESCRIPTION  	Microsoft Streets and Trips 2002/2003

#
# FILE LAYOUT DEFINITIIONS:
#
FIELD_DELIMITER  COMMA
RECORD_DELIMITER	NEWLINE
BADCHARS  ,"

PROLOGUE	Name,Latitude,Longitude,***Altitude***,Name 2,URL,Type

#
# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
# NOTE: MS S&T ONLY IMPORTS DATA, IT DOESN'T EXPORT THIS ANYWHERE SO WE CAN
#       HAVE OUR WAY WITH THE FORMATTING. 
#
IFIELD	SHORTNAME, "", "%s"  # Name
IFIELD	LAT_DECIMAL, "", "%f"  # Latitude
IFIELD	LON_DECIMAL, "", "%f"  # Longitude
***IFIELD  ALT_FEET, "", "%.2f"               # Altitude in Feet***
IFIELD	DESCRIPTION, "", "%s"  # Name 2 (Big Description)
IFIELD  URL, "", "%s"                   # URL
IFIELD	IGNORE, "", ""  	# Holder for Geocache Type

 

The sections in ***asterisked*** are additions to the existing file.

 

Then to use your new file, you tell the xcsv handler to get it's directions from your new file with the "style=xxx" directive. For example:

 

gpsbabel -i gpx -f my_waypoints.gpx -o xcsv,style=mycsv.style -F mine.csv

 

The README.style combined with the examples in the style directory should be enough to get you going.

 

If you have any other questions, please send them to the GPSBabel mailing list at gpsbabel-misc@lists.sourceforge.net. Although several of the developers of GPSBabel are geocachers, you're more likely to find a gpsbabel-aware audience there.

 

And if you create a new format that supports a currently unsupported application format, send it to the list also so it can be included with the standard "compiled in" style sheets and save someone else the hassle of creating it from scratch.

 

And if you haven't done it yet, you may want to get the Latest Release of GPSBabel, 1.2.0. More formats, more features, more fun. :)

 

Hope this helps!

 

Alex

Edited by alexm
Link to comment

Help Alex - Brian

 

Read about gpsbabel and downloaded a copy but I'm no programer - just run windows these days - got it to convert gpx files to Street Atlas files so I cah save the step of going into my GPS with the waypoints and then soutloading them to the Street atlas - Help me out on the procedure Please

 

thanks

BajaLou

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...