Like the fit_to_cols code I described recently, this code uses Kiyokazu Suto's Garmin::FIT package for Perl. Unlike fit_to_cols, this one needs to be able to write as well as read FIT data. The Garmin:FIT perl module allows this, but to figure out how you really need to dig into the provided example, fitsed. Fitsed is uncommented and does a lot more than just read and write FIT files: it also has a parser for selecting and/or changing fields in records. All good stuff, but a simple equivalent of hello.c, an example which minimally demonstrates writing FIT data, would have been useful. But I worked it all out, well most of it anyway, and my code seems to work.
So without further discussion, you can get it here (from Google Docs).
When downloading the code and placing it in your execution path, possibly typing "rehash" if you use a csh variant shell, the first thing to do is to type:
This prints help information.
Some examples, where "% " is the command prompt in these examples and is not typed:
- Check all files in the current directory for motorized segments. If any are found, then create a new FIT file for that file with ".fit" replaced with "_filtered.fit" :
% fit_filter_motor_segments *.fit
- The same as the previous example, but create new FIT files with the same name but in directory /tmp with segments identified as motorized, if any, stripped:
% fit_filter_motor_segments -a -dir /tmp *.fit
- From within Perl on a Linux or Unix based system, read an existing FIT file $ffit, filtering out the motorized segments (this is not a shell command, but rather Perl code):
open FP, "fit_filter_motor_segments < $ffit |" or die("error opening FIT file $ffit: $!\n");