However great GPSBabel can be, it still fails to be conversant with the great Columbus GPS logger. This is how we convert its CSV file to GPX.
Calling the piece of code below csv2gpx, simply run:
csv2gpx input.csv
This should produce a gpx as an output. To apply to all files in the folder:
for f in *.CSV; do csv2gpx "$f"; done
use strict; use warnings;
my $file = $ARGV[0] or die "Need to pass a CSV file as an input to process (Columbus P10 format)\n";
open(my $data, '<', $file) or die "Could not open '$file' $!\n"; open(OUT, '>' . $file.'.tmp') or die $!;
my $first_line = readline($data); print OUT $first_line; # We add 20 to the year, add / between year, month & day # and add : between hours:minutes:seconds while (my $line = <$data>) { my @fields = split "," , $line;
my $newfield2 = $fields[2]; my $newfield3 = $fields[3]; $newfield2 =~ s/(..)(..)/$1\/$2\//sg; $newfield3 =~ s/(..)(..)/$1\:$2\:/sg; print OUT $fields[0].",".$fields[1].",20".$newfield2.",".$newfield3.",".$fields[4].",".$fields[5].",".$fields[6].",".$fields[7].",".$fields[8]; } system("gpsbabel -i unicsv -f $file.'tmp' -o gpx -F $file.'aux.gpx'"); system("gpsbabel -i gpx -f $file.'aux.gpx' -x transform,trk=wpt,del -o gpx -F $file.'gpx'"); system("sed -i -E -- '/\<name\>|\<cmt\>|\<desc\>/d' $file.'gpx'");
system("rm $file.'aux.gpx'"); system("rm $file.'tmp'");