Universal csv with field structure in first line (unicsv)
Prev | Chapter 3. The Formats | Next

## Universal csv with field structure in first line (unicsv)

This format can...

- read and write waypoints

- read and write tracks

- read and write routes

This format has the following options: datum, grid, utc, format, filename, fields, codec .

Unicsv examines the first line of a file to determine the field order and field separator in that file. On write, it tries to figure out what data it has and writes headers and all the data it can.

Fields may be enclosed in double quotes. To include a double quote inside quotes escape it with another double quote.

If the first line contains any unenclosed tabs then the data lines are assumed to be tab separated. Otherwise if the first line contains any unenclosed semicolons then fields are assumed to be separated by semicolons. Otherwise if the first line contains any unenclosed vertical bars then fields are assumed to be separated by vertical bars. Otherwise the fields are assumed to be separated by commas.

The list of keywords include:

          alt =      Elevation (in meters).  For feet use "alt ft", "altft", "alt feet", or "altfeet".
          arch =     Geocache archived flag
          avail =    Geocache available flag
          bng_e =    British National Grid's easting
          bng =      full coordinate in BNG format (zone easting northing)
          bng_pos =  full coordinate in BNG format (zone easting northing)
          bng_n =    British National Grid's northing
          bng_z =    British National Grid's zone
          caden =    Cadence
          comment =  Notes
          cont =     Geocache container
          cour =     Heading / Course true
          date =     Date (yyyy/mm/dd)
          depth =    Depth (in meters).  For feet use "depth ft", "depthft", "depth feet", or "depthfeet".
          desc =     Description
          diff =     Geocache difficulty
          ele =      Elevation (in meters).  For feet use "ele ft", "eleft", "ele feet", or "elefeet".
          e/w =      'e' for eastern hemisphere, 'w' for western
          found =    Geocache last found date
          fix =      3d, 2d, etc.
          gcid =     Geocache cache id. This accepts GC-ID ("575006") and GC-Code ("GC1234G").
          geschw =   Geschwindigkeit (speed)
          hdop =     Horizontal dilution of precision
          head =     Heading / Course true
          heart =    Heartrate
          height =   Elevation (in meters).  For feet use "height ft", "heightft", "height feet", or "heightfeet".
          hint =     Geocache cache hint
          icon =     Symbol (icon) name
          lat =      Latitude
          lon =      Longitude
          name =     Waypoint name ("Shortname")
          n/s =      'n' for northern hemisphere, 's' for southern
          notes =    Notes
          pdop =     Position dilution of precision
          placer =   Geocache placer
          placer_id =Geocache placer id
          power =    Cycling power (in Watts)
          prox =     Proximity (in meters).  For feet use "prox ft", "proxft", "prox feet", or "proxfeet".
          sat =      Number of sats used for fix
          speed =    Speed, in meters per second. (See below)
          symb =     Symbol (icon) name
          tempf =    Temperature (degrees Fahrenheit)
          temp =     Temperature (degrees Celsius)
          terr =     Geocache terrain
          time =     Time (hh:mm:ss[.msec])
          type =     Geocache cache type
          url =      URL
          utc_d =    UTC date
          utc_t =    UTC time
          utm_c =    UTM zone character
          utm_e =    UTM easting
          utm =      full coordinate in UTM format (zone zone-ch easting northing)
          utm_pos =  full coordinate in UTM format (zone zone-ch easting northing)
          utm_n =    UTM northing
          utm_z =    UTM zone
          vdop =     Vertical dilution of precision
          x =        Longitude
          x_pos =    Longitude
          y =        Latitude
          y_pos =    Latitude
          z =        Elevation (in meters)

We support some enhanced Garmin attributes. They are also available in gpx, gdb, garmin_gpi and partly garmin_txt. These entities are currently not visible in MapSource™ (6.12.4), but are NOT dropped when working with GDB (version 3) or GPX files.

Please note, that these do NOT provide a geocoding service; don't expect to "convert" a street address to a latitude and longitude.

          addr =     Street address
          city =     City
          country =  Country
          faci =     Facility (not available in GPX)
          phone =    Phone number
          post =     Postal code
          state =    State

Fuller spellings (i.e. "longitude") may be used. You can also use keywords with a whitespace instead of an underscore.

A typical file may be:

         Name, Latitude, Longitude, Description
         GCEBB,35.972033,-87.134700,Mountain Bike Heaven by susy1313
         GC1A37,36.090683,-86.679550,The Troll by a182pilot & Family

If processing data from the UK, GPSBabel can process coordinates using X,Y values (often referred to as Eastings/Northings) as shown in Example 3.39, “CSV input for UK data with XY coordinates” or the full 12 figure alpha numeric, as shown in Example 3.40, “CSV input for UK data with alphanumeric coordinates”. Note in Example 3.40, “CSV input for UK data with alphanumeric coordinates” you need to split your original X,Y values into the 100Km 2 character code, eastings and northing values.

Example 3.39. CSV input for UK data with XY coordinates

           bng_e,bng_n,name,date
           353729,177210,id_001,2018/02/03
           356025,181221,id_002,2018/02/03
           357962,181528,id_003,2018/03/03

Example 3.40. CSV input for UK data with alphanumeric coordinates

           bng_z,bng_e,bng_n,name,date
           ST,53729,77210,id_001,2018/02/03
           ST,56025,81221,id_002,2018/02/03
           ST,57962,81528,id_003,2018/03/03

On the output side unicsv writes fixed number of columns (waypoint index, latitude and longitude) followed by a variable column list depending on internal data.

With at least ONE valid timestamp in data a unicsv output may look like that:

         No,Name,Latitude,Longitude,Description,Date,Time
         1,"GCEBB",35.972033,-87.134700,"Mountain Bike Heaven by susy1313",2003/06/29,09:00:00
         2,"GC1A37",36.090683,-86.679550,"The Troll by a182pilot & Family",,

For speed, a units specifier can be added to override the default. Here are some values, but check parse_speed() in parse.cc for the authoritative list.

- m/s, mps: meters per second

- km/h, kmh: kilometers per hour

- kt, knots: knots

- mph, mi/h, mih: miles per hour

### `datum` option

GPS datum (def. WGS 84).

This option specifies the datum to be used on output. Valid values for this option are listed in Appendix A, Supported Datums.

### `grid` option

Write position using this grid..

This value specifies the grid to be used on write. It is similar to the grid option of garmin_txt (see Table 3.1, “Grid values for garmin_txt”). The only difference is that unicsv does not write a degree sign (°) into the output file.

Without this option unicsv writes the coordinates as simple numbers like in the samples above.

### `utc` option

Write timestamps with offset x to UTC time.

This option specifies the local time zone to use when reading and writing times. It specifies a Universal Coordinated Time (UTC) offset in hours. For example, in the winter in Sweden the UTC offset is UTC+1, which corresponds to an option utc=1. Valid values are from -14 to +14.

### `format` option

Write name(s) of format(s) from input session(s).

When this option is enabled, we generate an additional 'Format' column. The values of this column are filled with names of previous input formats.

Example 3.41. Example for unicsv format option to write names of input formats.

The next example ... `gpsbabel -i gpx -f file1.gpx -i gdb -f file2.gdb -o unicsv,format=y -F result.txt` ... could produce following output:

No,Latitude,Longitude,Name,Description,Symbol,Date,Time,Format
1,51.075139,12.463689,"578","578","Waypoint",2005/04/26,16:27:23,"gdb"
2,51.081104,12.465277,"579","579","Waypoint",2005/04/26,16:27:23,"gdb"
3,50.844126,12.408757,"Gosel","Gosel","Exit",2005/02/26,10:10:47,"gpx"
4,50.654763,12.204957,"Greiz",,"Exit",2005/02/26,09:57:04,"gpx"

### `filename` option

Write filename(s) from input session(s).

When this option is enabled, we write an additional column called 'Filename'. The values of this column are filled with filenames of previous input formats.

This can be very helpful for locating specific waypoints (i.e. using the position filter) in more than one file.

Example 3.42. Example for unicsv filename option to write filenames of input formats.

The next example ... `gpsbabel -i gpx -f file1.gpx -i gdb -f file2.gdb -o unicsv,filename=1 -F result.txt` ... could produce following output:

No,Latitude,Longitude,Name,Date,Time,Filename
1,51.075139,12.463689,"578",2005/04/26,16:27:23,"reference/gdb-sample.gdb"
2,51.081104,12.465277,"579",2005/04/26,16:27:23,"reference/gdb-sample.gdb"
3,50.844126,12.408757,"580",2005/02/26,10:10:47,"reference/gdb-sample.gpx"
4,50.654763,12.204957,"581",2005/02/26,09:57:04,"reference/gdb-sample.gpx"

### `fields` option

Name and order of input fields, separated by '+'.

This option lets you specify the field names of your input file from the command line instead of relying on the first line of your input file describing the file. Field names are separated by a '+' character. The list of field names is exactly that allowed in the first line of a unicsv file without this option.

Example 3.43. Example for unicsv fields option to describe input file.

For example ... `gpsbabel -i unicsv,fields=lat+lon+description -f file.csv -o gpx -F file.gpx` declares that file.csv has three fields, latitude, longitude, and description, in that order.

### `codec` option

codec to use for reading and writing strings (default UTF-8).

This lets you override the default codec of 'UTF-8'. As an input option the codec should correspond to the encoding of the input file. As an output option it sets the encoding of the output file.

Prev | Up | Next
Textual Output (text) | Home | Vcard Output (for iPod) (vcard)