Using TextWrangler to edit Garmin, Zwift, Tacx and other .fit, .tcx and .gpx files

On the lost ride retrieval topic, I haven’t yet found a way to locate any surviving Tacx data from my iPad, but I have several times had cause to edit a Garmin ride file which wouldn’t upload to Strava.

Typically this has been because the ride data file has been corrupted, albeit quite innocently. On one occasion I paused my Garmin 705 and paused/unpaused it several times too rapidly to make sure I was hearing the right chirp or multiple chirp which indicates it is running (or not). This cause the file to be mis-recorded – I’ll come to that in a moment.

The most recent occasion was with my Garmin 520, which just switched itself off mid-ride. I turned it back on, and the ride appeared to be recorded normally, but would also not upload to Strava. On the 520, as with the more modern Garmin devices, it looks to an iPhone using the Garmin Connect app and bluetooth, and this ride would not synchronise to the phone either.

On both occasions I was able to repair the file using TextWrangler, an advance text editing application (on my MacBook Pro) that I use to create and edit web pages. It handles a file structure called “XML”, a structure that on a line by line basis creates tagged files that contain data in a repeating pattern enclosed by an open and closing tag for each data item such as heart rate, latitude and longitude and so on. Here is an example of two successive “Trackpoints” that the Garmin records every second or two during a ride:


The problem with the Garmin 705 failure was just that ONE of the opening tags <Trackpoint> was missing for one timestamp, so that the file was formatted incorrectly. Strava is VERY strict on accepting only correctly formatted files, so until I added this tag back in (there are thousands of them in any ride, 20,000 in that particular ride) Strava wouldn’t accept it; but even replacing just that one missing one meant that I could use the file for Strava.

On the second occasion with the 520, one timestamp at the point that the Garmin 520 turned itself off suddenly changed its date to a completely different day, and all the rest of the dates were similarly wrong for the rest of the file. Here are the two successive timestamps in question, with a sudden jump from 2016-11-27 to 2019-04-07! This was at line 23857 out of 84192 in the file altogether:

<trkpt lat=”55.931874252855777740478515625″ lon=”-4.27179764024913311004638671875″>
<trkpt lat=”55.9292156808078289031982421875″ lon=”-4.27936230786144733428955078125″>

This time, a simple global edit to make all of those (10,000) subsequent dates the same as the first 5,000 or so meant that the file was once more readable by Strava. In this case, Garmin Express on the MacBook WAS able to read the original file, as no doubt Garmin’s software is better at second guessing their own software glitches than Strava is, or is bothered to be! In general I find Garmin’s software leaves a lot to be desired, both on the Mac and also in their devices, but the 520/820 series are a lot better than previous models.

One final point: .fit files that are created and used by those more modern Garmin devices are not alphanumeric, so they aren’t easily correctable other than wth Garmin’s own web-based available software, which just tends to truncate any part of the file that has an error. But if you can read the file with the laptop applications Garmin Express or Garmin Basecamp, you can the export a .tcx or.gpx file from them which IS the tagged file structure you can edit in an application like TextWrangler. The .fit files don’t look very amenable in Textwrangler – ouch!:

 Tˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇ†ˇˇˇˇˇˇˇˇ #Eù2∫~√’ÁÈ͸/3Ù
 S¬≥ˇˇˇˇˇˇ@ˇˇˇˇˇˇˇˇ %Eù2√’XˆÍ¸∂9Ô
 Qˇˇˇˇˇˇˇˇ¿ˇˇˇˇˇˇˇˇmˇˇˇˇˇˇˇˇ (Eù2ë√’hθ0CÈ
 P ˇˇˇˇˇˇ )Eù2°√’/θ7FÁ
 Pöˇˇˇˇˇˇˇˇ—ˇˇˇˇˇˇˇˇ +Eù2…~√’ θzL·
 P¥ˇˇˇˇˇˇˇˇÄˇˇˇˇˇˇˇˇ -Eù2B}√’ï%θ±R€

Recovering from lost turbo rides in Zwift

Recently I have lost or partially lost Tacx rides using their trainer software on my iPad, and also had one lost Zwift ride.

For Zwift there is a way to recover partial rides if the software freezes, by peering into the iPhone or iPad with a laptop program called iMazing. It’s a chargeable program, but has a set of free functions which are enough to bring up the Zwift/activities folder in the iPad, from where stored .fit files  – and also image files if you have taken screenshots – can be copied to upload manually to Strava.

Zwift have the following advice on their support pages at

Finding your local .fit file

If for any reason you experience an issue, such as a game crash or Internet loss, your fit file is automatically saved every 10 minutes in the \Documents\Zwift\Activities folder on your computer.

If you’re riding on iOS, you can reach your .fit file through iTunes.

  1. Plug your device into your computer and open up iTunes.
  2. Click on your device in iTunes, then click “Apps” and scroll down to the “File Sharing” section.
  3. You should see Zwift listed, and it should have a “Zwift” folder. Click that, and then click “Save To” and save it to a location of your choice.
  4. Find the saved Zwift folder, and copy the fit file out of the Zwift/Activities folder.”

but I couldn’t find a way of saving the folder from iTunes to my laptop, although it is visible in iTunes where they say it is.

In any case, with iMazing you can pick off just the file you want, not necessarily the whole folder, so it’s a better way of doing it. Here are a couple of screenshots of what iMazing presents:

Apps in my iPhone as viewed from iMazing

Apps in my iPhone as viewed from iMazing

The Zwift rides and pictures within the Zwift/activities folder

The Zwift rides and pictures within the Zwift/activities folder


Using an ANT+ dongle for turbo training

The Tacx Flow, and other smart turbo trainers transmit and receive on Bluetooth as well as ANT+. So for a handheld or laptop with Bluetooth you should be OK with a smart turbo (although there does seem to be a Tacx limitation on the number of ANT+ channels available such that if using a Garmin GPS AND a laptop, one must be on Bluetooth if the other is on ANT+ dongle connection, or two dongles are required).

A heart strap would also need to transmit Bluetooth, though, if there is no ANT capability on the training software device, so for example if it’s a Garmin HRM that only sends ANT+ you’d need the dongle. I bought a dual HRM (sends both ANT+ AND Bluetooth) on Amazon called Coolspro, but I’m sure there are others.

I think a watch that measures and sends HR might work as well. Only issues with an ANT+ dongle for a handheld Apple device are a)  that mine (the Wahoo dongle) is designed for the older, larger lightning socket, so I also had to buy an adapter to connect into the current small lightning socket in the Apple handheld; b) the size of the older lightning plug means I have to take the cover off my iPhone or iPad to get it fully in; and c) the device’s power socket is also the lightning socket, so if using the dongle you have to make sure the handheld is well charged before the turbo session. All in all, it’s better to use Bluetooth, which I have found has less dropouts, that are REALLY annoying as all ride data gets lost.

I now use a piece of MacBook s/w called iMazing that lets you find files inside an attached iPad or iPhone, and even incomplete Zwift .fit ride files are stored in the Zwift/activities folder that you can find in iMazing, copy over to the MacBook and then upload to Strava as a manual entry. Any screenshots you take during a Zwift ride are there too. I haven’t found a way of doing that for incomplete Tacx rides. Btw Tacx have a cloud site where all your completed rides CAN be uploaded by default so you never lose a ride even if you lose your handheld!

The Brachistochrone problem


I was struck by this GiF recently, at:


This little video shows three possible paths – the straight line (the shortest), a path that descends quickly and then becomes flat as it gets to the destination, and one in between, looking more elliptical* in shape.

Ever wondered what downhill profile of road will get you most quickly to the bottom of the hill freewheeling from a given point T (the top) to a given point P (the pub)? Now you know – it’s a cycloid, appropriately enough. Now I just need to think about the best shape of road from the pub to the top for the fastest ascent for a given a) wattage, and b) for a given pedal pressure…

…The classical problem is well-known as the difficult to solve Brachistochrone problem. See…/m231f08/m231f08brachistochrone.pdf for a solution – minimising a quantity over a famiły of functions, or…/nishiyama/math2010/cycloid.pdf which is perhaps a little more accessible and talks a little more about the cycloid (the resolution of the problem).

Even more arcanely (I was going to say more interestingly, but I’m realistic about reading endurance!) the cycloid, as the second article says, is isochronous. It means that even if you start freewheeling from a rest position R half way down the hill, it still takes the same time to get to the pub. Why? Briefly, because starting higher up, at the intermediate point R you are moving, whereas starting from R you are at rest. Weird, huh? It’s the same for any point R, no matter how close to the pub.

*the elliptical path is nearly as fast as the cycloid – but not quite!!

The tacx concept of “Virtual speed”

I have another interesting quirk to discuss with you relating to my Tacx Flow turbo, or indeed any other Tacx turbo that has a relatively low maximum slope simulation capability (i.e. other than the Neo, i-Genius or Bushido) such as the Flow at 6% max or the Vortex at 7% max. This is from the Tacx support pages

“When a trainer cannot apply enough resistance, the measured speed does not comply with your exercise (training program) anymore.
To solve this the speed is calculated (Virtual Speed) based on the power you are producing and the exercise data (current slope).

“e.g. You are riding an exercise which consists of a single 10 % slope on a trainer which can only apply enough resistance to simulate a 7 % slope.

“Using measured speed you will finish the exercise much sooner compared to actually riding the same 10 % slope in real life, because the trainer cannot apply enough resistance causing you to go faster resulting in the exercise costing you less effort.

“Using virtual speed your exercise will be much closer to actually riding the same 10 % slope in real life, because it calculates how fast you would be going on a 10 % slope based on the effort (power) you are producing on the trainer

“Keep in mind speed shown in TCA is also NOT the raw speed from the trainer. It’s always calculated with the same virtual speed calculations but not flagged as virtual speed cause it’s less than 10% deviation from the RAW speed of the trainer.

“Measured speed from a sensor is treated as raw speed.”

So if you use a speed/cadence sensor with your turbo bike, you will get raw speed recorded, allegedly. I have certainly noticed downhill speeds being greater then I would have thought, and uphill speeds possibly slower (but then that may be my issue!)

On the retailer Wiggle’s site I see it asserted that apparently Zwift have partnered with Strava to allow virtual rides to count towards Challenges if you use such a sensor (as I am only riding turbo at the moment, I have zero distance and elevation in Strava Challenges for January, and probably December too). My personal targets are as normal. See:

Never mind the potholes on a real road; on a turbo, it’s a minefield out there!

Zwift’s “difficulty setting”

Here’s a very interesting article with, for me, some initially counter-intuitive outcomes – until I thought about it more.

For context, I’m using the Smart Tacx Flow as an alternative to my non-Smart i-Genius trainer (a contradiction in terms…).. The Flow goes up to 6% incline and 750W. No motor for downhill, but it DOES reduce the flat riding resistance which can be felt to about 3% downhill, and then it stays the same. No motor means if I stop pedalling it eventually stops whether up or downhill. For my money it’s great value. I reckon it’s swings and roundabouts on 6% max and no motor compared to I-Genius. I work harder on big downhills but less hard on steeper hills. The Zwift “difficulty setting” offers a way to make the 6% hills and above feel tougher…

The article at describes resetting the resistance levels when using Zwift to increase or reduce the multiple of training effort for any given slope, WITH NO CHANGE TO THE WATTS REQUIRED. How can that be, one might ask? Surely, if you increase the resistance multiple for any hill, thereby increasing pedal pressure (the intention of the change (in my case) to circumvent the Flow’s 6% max slope simulation) then isn’t the power (pedal force X speed = work rate) increased, or do they reckon because you are likely to reduce cadence (for a given gear) as a result, the speed diminishes in proportion with the increase in pedal pressure?

Having a PhD in Theoretical Physics means I’m a little ashamed of myself even to have a momentarily different intuition initially! But people of my age who did Applied Maths at school ought to remember the old Horsepower formula HP = Pv/550 (in appropriate units). Power is proportional to the multiple of force P and velocity v. It’s why some sports car manufacturers used to be so fond of highlighting their cars’ horsepower, because by making their engines rev at very high revs (enhancing engine wear no end) they could advertise very high horse-power. Very UNusable power, given how high you had to rev in all the low gears to get performance. The American way was to make engines bigger and bigger (427 cubic inch (7 litre) V8 preferably) so that TORQUE (turning force) was very high and the engines were just ticking over at quite high speeds, generating power at much more usable revs. Even smaller diesels (whose fuel characteristic is different from petrol) produce high torque at low revs too, compared to lighter, faster revving petrol engines.

As for cycling, and using the Zwift “difficulty setting” to change the perceived resistance, I guess, as the article says, just like the automobile analogy, it’s really a cadence control. You push harder on the pedals, say, but at lower revs, so the power is the same. Watch those quads grow!

Some Tacx, Zwift and turbo training learnings

Having used the Tacx non-smart i-Genius turbo trainer for a while, I have also been using my Tacx smart Flow trainer a lot recently.

The Tacx Flow is great value, the lowest price Tacx trainer that is fully smart, i.e. ANT FE-C and Bluetooth bidirectional. Thus the trainer software (Tacx films or 3rd party like Zwift, on laptop or handheld device where applicable) will control the Flow brake, and the Flow sends all speed, power and cadence data to the training software.

You can also control a smart trainer like the Tacx Flow with the Garmin x20 series, i.e. such as the 520 or 820 that have the right data protocols.

At this low end of the Tacx range, you are limited to 6% uphill simulation and 750W power, but I don’t find this too much of an issue. Because it doesn’t have a motor to help simulate downhill freewheeling (like the I-Genius I also have) you work harder downhill to make up for it being easier at 7% uphill and above because the resistance is limited to simulating 6% max.

The Tacx Vortex does 7% and 950W but not worth quite a bit extra price in my opinion. I have published quite a bit on all this on Facebook to my cycling Club I have also described how Zwift offers the option of increasing what they call “difficulty” from the default standard 50% to something higher. This increases resistance on hills, lowering cadence and speed and leaving power the same.

Tacx have something called “virtual speed” which decreases reported speed uphill and increases it downhill to compensate for the maximum simulated uphill and downhills on trainers like the Flow and Vortex.

The much more expensive Tacx Neo, Genius and Bushido don’t need that.

DCRainmaker always offers good information, especially his “all you wanted to know…” page which is at
32 minutes ago

A visit to the Westerham Cyclery

Having seen this excellent blog post on Facebook about the Westerham Cyclery,

Westerham Cyclery at the Green

Westerham Cyclery at the Green

and linked to it from there – I thought I should add my own pictures and very positive comments, having been hosted into hosted by their very friendly staff!img_6246 I went there to meet up with a cycling Glasgow Green Cycle Club friend, Susie Goodwin, and then to ride one of the climbs back over the North Downs.


The cake options, with second piece of bread pudding!

The highlight of my visit, I have to own up to, was the (two pieces of!) bread pudding, but they have all sorts of cakes and drinks, plus a well stocked bike shop, a very safe place in the courtyard to park (and lock if desired) the bike, and tables and seats in that courtyard for

My first helping of bread pudding

My first helping of bread pudding

a quiet al fresco rest.

img_6244I am based near Glasgow in Scotland, but now, added to the Spitfire café in Biggin Hill, Westerham Cyclery will be at the top of list for my next ride south of London when visiting family. The café garden is a great place to meet people and relax.

img_6336From a riding point of view, there are quite a few climbs back over the North Downs, including Chalkpit Lane which I rode on another visit. My first return was via the signposted route from Westerham to Croydon, which is a more gentle climb that anyone can manage, so go ahead and make a visit!