Define CSV Output Format for ForeFlight

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Define CSV Output Format for ForeFlight

Guy Fisher

Hello,

ForeFlight iPad app is an advanced commercial GPS app for pilots
It supports importing CSV waypoint files but the file has to be specific format:

Name,Description,Lat,Long

Name must be in CAPS and no spaces (underscores or dashes permitted).

I'm using Mac.
I designed a style format, see attache "ForeFlight.style" file.

When launching GPSBabelFE, I don't see XCSV option in the Output File Format dropdown list box.
Also don't see where I can specify the file type format.

Would appreciate some help and guidance.

Perhaps this output file format can be added to the application?
It would benefit many pilots.

Thank you,

Guy-Fisher---Signature-Animated-Small(Jellyka_Estrya_Handwriting-Font).gif

 



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc

ForeFlight.style (866 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Define CSV Output Format for ForeFlight

Robert Lipe-4
Hi, and welcome.

For your first implicit question, custom xcsv styles aren't supported in the GUI.  If have GPSBabel installed in the common place on a Mac, you can run the underlying GPSBabel shipped in the GUI like:

$ /Applications/GPSBabelFE.app/Contents/MacOS/gpsbabel  -i geo -f geocaching.loc -o xcsv,style=$HOME/Downloads/ForeFlight.style -F -

Obviously, this is reading a "geo" file in the current directory named "geocaching.loc"

For your actual question, yes, it can be added to the official repository and thus be included in future versions or immediately for those building from source.  We'd need a page for our doc.  Ideally, that would be in xmldoc format that we can just drop in, but if you look at any of our doc pages and can provide the words (what does this format do, what versions of what programs does it support, how do you use it, etc.) I can add the angle bracket decorations.

Now for the question you didn't actually ask: I don't think this file does what you think it does and I really don't see how you could implement it using only the existing xcsv format.  This would be a much better fit for a "real" C++ module.  Let's feed it one of our own reference files and look at the first ten lines:

$ /Applications/GPSBabelFE.app/Contents/MacOS/gpsbabel  -i gpx -f reference/linestyles.gpx -o xcsv,style=$HOME/Downloads/ForeFlight.style -F - | head
Name Description Latitude Longitude
HirDh0,HirDh0,37.538136,-122.291541
ThinDh0,ThinDh0,37.535986,-122.291663
RdHir0,RdHir0,37.533444,-122.292032
RdThin0,RdThin0,37.530854,-122.292277
RdMd0,RdMd0,37.528654,-122.292584
RdThik0,RdThik0,37.524989,-122.292646
YllowMd0,YllowMd0,37.520199,-122.292093
GrnMd0,GrnMd0,37.517951,-122.291847
BluMd0,BluMd0,37.515653,-122.291970

If you look at their example, file, there is no "NAME DESC..." header and everything is all on one line with individual recrods separated by newlines, not carriage return/newline pairs.  There is no enforcement of their (kinda goofy) requirement of

Waypoint names must:

Be at least 3 characters long including at least one letter.
Be ALL CAPS.
Be one word with no spaces.

...and without changes in our XCSV implementation, none of those are actually enforceable.  I'm guessing that anybody selling a $100 program in 2015[1] that supports only upper case letters probably left out additional requirements like I'm guessing it actually means American letters and that umlauts and grave accents aren't particularly welcome.  Is there a way to get a comma in a waypoint name via quoting or is that disallowed? What's the character set used?  Is it really effectively 6-bit ASCII or is it something like ISO-8859-1 or (gasp) Windows-1252?

If they actually support OGC KML, that's probably a lower friction entry path to get data into this format.  We can write KML.  Of course, if their definition of "KML" imposes the same goofy naming requirements above and not the actual definition of KML, you still have a problem, as our KML writer doesn't know how to enforce those stated restrictions, either.

The good news is that even if we make reasonable guesses at the above and treat the rest as "fix on fail" (i.e. wait for a bugreport involving umlauts and let that person work out with the creator of ForeFlight what the rules ACTUALLY are and then implement them) since this looks like an output-only format, it's not THAT complicated as a C++ module, just doing things like adding "WPT" before anything < 3 characters, stripping commas completely, etc. and force Latin1 and then crossing other encoding issues if it comes down to it. Wouldn't be terribly difficult to implement for even a budding coder, but certainly more complicated than a style definition.

RJL


[1] 20 years ago when we were hand-coding assembly for US-only products on a battery-powered DragonBall, I understood why things were US-centried and upper case only...On an iPad, that's pretty embarrassing. I do understand how an app targeting US Pilots may not need to load arbitrary data in bulk from a large variety of input sources, but "upper case only" just seems weird.


On Sat, Oct 31, 2015 at 9:23 PM, Guy Fisher <[hidden email]> wrote:

Hello,

ForeFlight iPad app is an advanced commercial GPS app for pilots
It supports importing CSV waypoint files but the file has to be specific format:

Name,Description,Lat,Long

Name must be in CAPS and no spaces (underscores or dashes permitted).

I'm using Mac.
I designed a style format, see attache "ForeFlight.style" file.

When launching GPSBabelFE, I don't see XCSV option in the Output File Format dropdown list box.
Also don't see where I can specify the file type format.

Would appreciate some help and guidance.

Perhaps this output file format can be added to the application?
It would benefit many pilots.

Thank you,

Guy-Fisher---Signature-Animated-Small(Jellyka_Estrya_Handwriting-Font).gif

 



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
Reply | Threaded
Open this post in threaded view
|

Re: Define CSV Output Format for ForeFlight

Guy Fisher
Hello,
Very detailed response. Really appreciate that. 
I'm not a programmer so don't know how to code this in C++ or program xmldoc. 
I'm not sure what I need to do or how I can help, so that foreflight weird file format can be supported in gpsbabel.  But it would be really nice to have this. 

The advantage of CAV files is I can easily load them in Excel and make a bunch of changes before importing into foreflight. KML is very complex to edit, at least for me with little knowledge of XML file types. 

Currently I convert files for foreflight by loading exported CSV files in Excel and then after deleting header rows, routes and tracks it needs shifting columns around so they are in the right order then resale the file. Workflow is very time consuming and tedious. 

Thank you. 

Guy-Fisher---Signature-Animated-Small(Jellyka_Estrya_Handwriting-Font).gif

.


On Nov 1, 2015, at 14:07, Robert Lipe <[hidden email]> wrote:

Hi, and welcome.

For your first implicit question, custom xcsv styles aren't supported in the GUI.  If have GPSBabel installed in the common place on a Mac, you can run the underlying GPSBabel shipped in the GUI like:

$ /Applications/GPSBabelFE.app/Contents/MacOS/gpsbabel  -i geo -f geocaching.loc -o xcsv,style=$HOME/Downloads/ForeFlight.style -F -

Obviously, this is reading a "geo" file in the current directory named "geocaching.loc"

For your actual question, yes, it can be added to the official repository and thus be included in future versions or immediately for those building from source.  We'd need a page for our doc.  Ideally, that would be in xmldoc format that we can just drop in, but if you look at any of our doc pages and can provide the words (what does this format do, what versions of what programs does it support, how do you use it, etc.) I can add the angle bracket decorations.

Now for the question you didn't actually ask: I don't think this file does what you think it does and I really don't see how you could implement it using only the existing xcsv format.  This would be a much better fit for a "real" C++ module.  Let's feed it one of our own reference files and look at the first ten lines:

$ /Applications/GPSBabelFE.app/Contents/MacOS/gpsbabel  -i gpx -f reference/linestyles.gpx -o xcsv,style=$HOME/Downloads/ForeFlight.style -F - | head
Name Description Latitude Longitude
HirDh0,HirDh0,37.538136,-122.291541
ThinDh0,ThinDh0,37.535986,-122.291663
RdHir0,RdHir0,37.533444,-122.292032
RdThin0,RdThin0,37.530854,-122.292277
RdMd0,RdMd0,37.528654,-122.292584
RdThik0,RdThik0,37.524989,-122.292646
YllowMd0,YllowMd0,37.520199,-122.292093
GrnMd0,GrnMd0,37.517951,-122.291847
BluMd0,BluMd0,37.515653,-122.291970

If you look at their example, file, there is no "NAME DESC..." header and everything is all on one line with individual recrods separated by newlines, not carriage return/newline pairs.  There is no enforcement of their (kinda goofy) requirement of

Waypoint names must:

Be at least 3 characters long including at least one letter.
Be ALL CAPS.
Be one word with no spaces.

...and without changes in our XCSV implementation, none of those are actually enforceable.  I'm guessing that anybody selling a $100 program in 2015[1] that supports only upper case letters probably left out additional requirements like I'm guessing it actually means American letters and that umlauts and grave accents aren't particularly welcome.  Is there a way to get a comma in a waypoint name via quoting or is that disallowed? What's the character set used?  Is it really effectively 6-bit ASCII or is it something like ISO-8859-1 or (gasp) Windows-1252?

If they actually support OGC KML, that's probably a lower friction entry path to get data into this format.  We can write KML.  Of course, if their definition of "KML" imposes the same goofy naming requirements above and not the actual definition of KML, you still have a problem, as our KML writer doesn't know how to enforce those stated restrictions, either.

The good news is that even if we make reasonable guesses at the above and treat the rest as "fix on fail" (i.e. wait for a bugreport involving umlauts and let that person work out with the creator of ForeFlight what the rules ACTUALLY are and then implement them) since this looks like an output-only format, it's not THAT complicated as a C++ module, just doing things like adding "WPT" before anything < 3 characters, stripping commas completely, etc. and force Latin1 and then crossing other encoding issues if it comes down to it. Wouldn't be terribly difficult to implement for even a budding coder, but certainly more complicated than a style definition.

RJL


[1] 20 years ago when we were hand-coding assembly for US-only products on a battery-powered DragonBall, I understood why things were US-centried and upper case only...On an iPad, that's pretty embarrassing. I do understand how an app targeting US Pilots may not need to load arbitrary data in bulk from a large variety of input sources, but "upper case only" just seems weird.


On Sat, Oct 31, 2015 at 9:23 PM, Guy Fisher <[hidden email]> wrote:

Hello,

ForeFlight iPad app is an advanced commercial GPS app for pilots
It supports importing CSV waypoint files but the file has to be specific format:

Name,Description,Lat,Long

Name must be in CAPS and no spaces (underscores or dashes permitted).

I'm using Mac.
I designed a style format, see attache "ForeFlight.style" file.

When launching GPSBabelFE, I don't see XCSV option in the Output File Format dropdown list box.
Also don't see where I can specify the file type format.

Would appreciate some help and guidance.

Perhaps this output file format can be added to the application?
It would benefit many pilots.

Thank you,

Guy-Fisher---Signature-Animated-Small(Jellyka_Estrya_Handwriting-Font).gif

 



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
SRE
Reply | Threaded
Open this post in threaded view
|

KML to GPX has missing waypoints (look inside MultiGeometry tag?)

SRE
In reply to this post by Robert Lipe-4
I'm somewhat of a novice in Google Earth, but I found some places by searching and
copying the search results to My Places. I created a sub-folder and dragged a couple
of waypoints into it (as a web search indicates I must to export more than one waypoint
at a time). Right-click on that folder, choose SavePlaceAs, choose KML, seems to work.
I can close Earth and get all my points back by double-clicking the KML file.

My stripped down a test case has one Placemark which I clicked on the map to create,
and one which was originally a search result. The KML file shows them both as
Placemark tags, but with different IDs (1.2.2 vs. 1.6.2). Other tests have gotten
me KML files with no ID field at all in the Placemark tag.

GPSBabel reports no errors:
  | gpsbabel -w -r -t -i kml -f ./MissingPlacemark.kml -x simplify,count=450 -o gpx,suppresswhite=1 -F ./MissingPlacemark.gpx
  | Translation successful

But the GPX file has only one waypoint! KML and GPX files are attached. Other than
replicating every place in my file as a newly minted pushpin style placemark, how do
I get all of the My Places in the KML file to show up as Waypoints in the GPX file?

UPDATE: (glad I didn't send sooner) I think the ID doesn't matter, and the REAL difference
is that one place has MultiGeometry tags around the Point tag. I deleted those tags
(see Edited.kml) and got both waypoints in the output (see Edited.gpx). That means the
simple fix would be to look inside MultiGeometry for a Point if there is no exposed
Point in the Placemark.

I was not sure which list to post this on, maybe someone else has a fix or workaround already??

Steve
------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc

MissingPlacemark.kml (11K) Download Attachment
MissingPlacemark.gpx (7K) Download Attachment
Edited.kml (10K) Download Attachment
Edited.gpx (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: KML to GPX has missing waypoints (look inside MultiGeometry tag?)

Robert Lipe-4
Thank for the detailed report.  MultiGeometry is definitely one of those KML things that doesn't map cleanly to most other consumer-grade formats.  It looks like we treat a LineString in a MultiGeometry in a Placemark exactly like a track, but we do the same for a LinearRing which would also map most closely to our concept of Tracks internally (and to GPX).

My guess is that replacing LinearRing with LineString in your KML would have also brought joy.

There's a lot going on in that file that we just can't deal with such as the ExtendedData and styling, but I don't see a LinearRing being rendered even in Earth.  That may just be an artifact of you reducing the KML to a smaller one. (And thank you for that...)

Since I recall you're a developer, look for the line in kml.cc that says
  { trk_coord,  cb_cdata,       "/Placemark/MultiGeometry/LineString/coordinates" },
and add one below it that says
  { trk_coord,  cb_cdata,       "/Placemark/MultiGeometry/LinearRing/coordinates" },
..and see if that brings joy to your life.

Oh, and Earth will make up id's within a file; they're not persisted or stable. that's OK as long as they're unique within a unit; I just can't recall if that unit is KML or KMZ.

On Mon, Nov 2, 2015 at 3:46 PM, SRE <[hidden email]> wrote:
I'm somewhat of a novice in Google Earth, but I found some places by searching and
copying the search results to My Places. I created a sub-folder and dragged a couple
of waypoints into it (as a web search indicates I must to export more than one waypoint
at a time). Right-click on that folder, choose SavePlaceAs, choose KML, seems to work.
I can close Earth and get all my points back by double-clicking the KML file.

My stripped down a test case has one Placemark which I clicked on the map to create,
and one which was originally a search result. The KML file shows them both as
Placemark tags, but with different IDs (1.2.2 vs. 1.6.2). Other tests have gotten
me KML files with no ID field at all in the Placemark tag.

GPSBabel reports no errors:
  | gpsbabel -w -r -t -i kml -f ./MissingPlacemark.kml -x simplify,count=450 -o gpx,suppresswhite=1 -F ./MissingPlacemark.gpx
  | Translation successful

But the GPX file has only one waypoint! KML and GPX files are attached. Other than
replicating every place in my file as a newly minted pushpin style placemark, how do
I get all of the My Places in the KML file to show up as Waypoints in the GPX file?

UPDATE: (glad I didn't send sooner) I think the ID doesn't matter, and the REAL difference
is that one place has MultiGeometry tags around the Point tag. I deleted those tags
(see Edited.kml) and got both waypoints in the output (see Edited.gpx). That means the
simple fix would be to look inside MultiGeometry for a Point if there is no exposed
Point in the Placemark.

I was not sure which list to post this on, maybe someone else has a fix or workaround already??

Steve
------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc



------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
SRE
Reply | Threaded
Open this post in threaded view
|

Re: KML to GPX has missing waypoints (look inside MultiGeometry tag?)

SRE
At 02:12 PM 11/3/2015, Robert Lipe wrote:
>There's a lot going on in that file that we just can't deal with

No kidding! It's a mess.

>I don't see a LinearRing being rendered even in Earth.

It was just a waypoint, no track. The Point tag (just before the LinearRing tag) contains the data.

>That may just be an artifact of you reducing the KML to a smaller one. (And thank you for that...)

I entered only two points in Earth, then sent the entire KML that Earth wrote (without further editing except the second KML had the MultiGeometry tag deleted with vi).

>Since I recall you're a developer, look for the line in kml.cc that says
>Â  { trk_coord, Â cb_cdata, Â  Â  Â  "/Placemark/MultiGeometry/LineString/coordinates" },
>and add one below it that says
>Â  { trk_coord, Â cb_cdata, Â  Â  Â  "/Placemark/MultiGeometry/LinearRing/coordinates" },
>..and see if that brings joy to your life.

I probably can't get to it for a week or two, but thanks for the pointer.

On the other hand... are you sure this will expose the Point and Coordinates which GPSBabel found after I deleted the MultiGeometry tag (and the end tag) ?  After that edit, LinearRing was at the same level as Point.

Steve


------------------------------------------------------------------------------
_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
Reply | Threaded
Open this post in threaded view
|

Re: KML to GPX has missing waypoints (look inside MultiGeometry tag?)

Robert Lipe-4
>I don't see a LinearRing being rendered even in Earth.

It was just a waypoint, no track. The Point tag (just before the LinearRing tag) contains the data.

Right. But Earth isn't rendering the LinearRing that I can tell.

>Since I recall you're a developer, look for the line in kml.cc that says
>  { trk_coord,  cb_cdata,       "/Placemark/MultiGeometry/LineString/coordinates" },
>and add one below it that says
>  { trk_coord,  cb_cdata,       "/Placemark/MultiGeometry/LinearRing/coordinates" },
>..and see if that brings joy to your life.

I probably can't get to it for a week or two, but thanks for the pointer.

I recall you're comfortable in code, so I've at least given you a specific pond to fish in, though not necessarily a meal.
 
On the other hand... are you sure this will expose the Point and Coordinates which GPSBabel found after I deleted the MultiGeometry tag (and the end tag) ?  After that edit, LinearRing was at the same level as Point.

Absolutely not. :-)

We do have ways of ignoring levels of tags in KML (poorly tested and horribly implemented) and some other tricks up our sleeves if that falls out.  But if copy/pasting one line and making a mechanical edit does the trick, there's no reason to try the hard approaches.

KML and GPX are just world apart in the problems they try to solve.  Yes, they each have concepts of lines and points, but when KML gets down with nested folders, embedded styles, extended data, camera views, embedded video, animated music that's synchronized to passing a point and such, there's a lot that just can't be stuffed into a Garmin 60C...and GPSBabel's internal data structures more closely match the latter than KML's model.  GPX was similarly influenced by what GPSes at the turn of the century did.


RJL 

------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
SRE
Reply | Threaded
Open this post in threaded view
|

Re: Define CSV Output Format for ForeFlight

SRE
In reply to this post by Guy Fisher
I got interested in this problem because there is a generic solution to stripping off
a header line and swapping comma-separated columns if you make some assumptions.
Hopefully you and others who search for a solution will find this useful.

At 11:17 PM 11/1/2015, Guy Fisher wrote:
>I'm not sure what I need to do or how I can help, so that foreflight weird file
>format can be supported in gpsbabel.  But it would be really nice to have this.

Here's a really crude hack that may solve your problem. It could be done far more
elegantly in Perl, or with extended regular expressions in sed, but trying for the
lowest-common-denominator (read "robust") solution was my goal. Note that this will
FAIL if your values have commas or double quotes in them, or if your GPX file has
different fields than the test case you sent. Both can be worked around, but this
isn't a product, it's a hack!

The CSV file I tested with came out of GPSBabel so the first line has field names.

If your Mac has a unix-style command line, paste the 11 lines below into a file
called something like "script.sh" and make sure the file attributes allow you to
execute it (chmod +x script.sh). Then at the command line type run
        ./script.sh file.csv
which should produce file.csv.out and some stroking output about what happened.

The sample file you sent had these fields:
>No,Latitude,Longitude,Name,Altitude,Description,Symbol,Depth,Date,Time
BUT if your GPX file has other fields (more or less) this script will need editing to match!

#!/bin/sh
echo Reading file $1
FIRST=`head -1 $1`
echo "First line: $FIRST"
echo "Extracting first 6 fields and writing only 4, 6, 2, 3..."
echo $FIRST | sed 's/^\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),.*/\4,\6,\2,\3/'
# skip the  first line, process the rest to keep only 4 columns in a different order
# post-process the output to ditch double quotes and turn all spaces into underscores
tail -n +2 $1 | sed 's/^\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),.*/\4,\6,\2,\3/' | sed 's/"//g' | sed 's/ /_/g' > $1.out
echo Output written to $1.out
exit

(that worked under Linux on a virtual machine, YMMV, proof is left to the student, etc)

Steve


------------------------------------------------------------------------------
_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc
Reply | Threaded
Open this post in threaded view
|

Re: Define CSV Output Format for ForeFlight

Robert Lipe-4
You may find awk less punctuation-ful.

$ echo a,b,c,d,e,f | awk -F, '{print $5, "," $1}'

e ,a

On Wed, Nov 18, 2015 at 1:49 PM, SRE <[hidden email]> wrote:
I got interested in this problem because there is a generic solution to stripping off
a header line and swapping comma-separated columns if you make some assumptions.
Hopefully you and others who search for a solution will find this useful.

At 11:17 PM 11/1/2015, Guy Fisher wrote:
>I'm not sure what I need to do or how I can help, so that foreflight weird file
>format can be supported in gpsbabel.  But it would be really nice to have this.

Here's a really crude hack that may solve your problem. It could be done far more
elegantly in Perl, or with extended regular expressions in sed, but trying for the
lowest-common-denominator (read "robust") solution was my goal. Note that this will
FAIL if your values have commas or double quotes in them, or if your GPX file has
different fields than the test case you sent. Both can be worked around, but this
isn't a product, it's a hack!

The CSV file I tested with came out of GPSBabel so the first line has field names.

If your Mac has a unix-style command line, paste the 11 lines below into a file
called something like "script.sh" and make sure the file attributes allow you to
execute it (chmod +x script.sh). Then at the command line type run
        ./script.sh file.csv
which should produce file.csv.out and some stroking output about what happened.

The sample file you sent had these fields:
>No,Latitude,Longitude,Name,Altitude,Description,Symbol,Depth,Date,Time
BUT if your GPX file has other fields (more or less) this script will need editing to match!

#!/bin/sh
echo Reading file $1
FIRST=`head -1 $1`
echo "First line: $FIRST"
echo "Extracting first 6 fields and writing only 4, 6, 2, 3..."
echo $FIRST | sed 's/^\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),.*/\4,\6,\2,\3/'
# skip the  first line, process the rest to keep only 4 columns in a different order
# post-process the output to ditch double quotes and turn all spaces into underscores
tail -n +2 $1 | sed 's/^\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),.*/\4,\6,\2,\3/' | sed 's/"//g' | sed 's/ /_/g' > $1.out
echo Output written to $1.out
exit

(that worked under Linux on a virtual machine, YMMV, proof is left to the student, etc)

Steve


------------------------------------------------------------------------------
_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc


------------------------------------------------------------------------------

_______________________________________________
Gpsbabel-misc mailing list http://www.gpsbabel.org
[hidden email]
To unsubscribe, change list options, or see archives, visit:
https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc