This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A solution for combining/merging two TCX files (activies)

Former Member
Former Member
This weekend I needed to adjust my interval workout while it was in progress (yes, I needed a break!) This resulted in me having two different activities and two TCX files for each.

I searched and downloaded various software, but they didn't do exactly what I wanted. (Some didn't preserve the calories, and some turned the workout into a course, etc)

I then tried just copying all the laps from one TCX to the other using notepad, but that didn't work either. The distance was corrupt when I uploaded to Garmin Connect. I realized that the the individual laps in each activity have a cumulative distance tracker. So all I needed to do to make this work is offset the last distance tracked to all of the distances from the other activity.

I created a simple XSLT transform that can be applied to two TCX files and it will create a new merged activity.

Thought I'd share.

(Note, you'll need a XSLT processor like saxon/xalan or others)
  • Former Member
    0 Former Member over 13 years ago
    I just read this and had to laugh. Seriously - XSLT, java tools, notepad editing!? :eek:

    Or.. install SportTracks, pick the two workouts, and click "Join".

    Done.

    If you're not happy with the new workout - just edit the track.

    You've got bettter things to do than fiddling with text editing tools - like hitting the road.

    Just sayin.
  • TrailRunnerX

    This weekend I needed to adjust my interval workout while it was in progress (yes, I needed a break!) This resulted in me having two different activities and two TCX files for each.


    I had the same problem, and (after a lot of searching for solutions) ended up using TrailRunnerX (trailrunnerx.com, Mac OS only). The user interface is so-so, but I did manage to successfully combine my two TCX files, preserving information about heart rate, speed, elevation, etc.
  • Former Member
    0 Former Member over 13 years ago
    Good work. I used the application to build a non recorded activity from two manually entered activities. Why you may ask? Well bloody Garmin in their infinite wisdom does not allow for laps to be input for manual activities.

    I was able to make an activity for each of my 1k swim times to get 2 laps for my 2k swim :> Your great lil program allowed me to combine the exported TCX into a single file and re import.

    Again thank to Garmin it put it in an import directory but you can move it via the context menu (but not drag and drop thanks Garmin ... do you see a theme yet?).
  • Former Member
    0 Former Member over 12 years ago
    Corrupted tcx file after merging with java version

    I just tried the Java version, the second Track has "NaN" in the DistanceMeters field
    Any idea what went wrong?


    ...
    <Trackpoint>
    <Time>2012-05-26T13:00:35.000Z</Time>
    <AltitudeMeters>61.20000076293945</AltitudeMeters>
    <DistanceMeters>8481.419921875</DistanceMeters>
    <HeartRateBpm>
    <Value>128</Value>
    </HeartRateBpm>
    <Extensions>
    <TPX xmlns="www.garmin.com/.../v2">
    <Speed>0.0</Speed>
    </TPX>
    </Extensions>
    </Trackpoint>
    <Trackpoint>
    <Time>2012-05-26T13:00:36.000Z</Time>
    </Trackpoint>
    </Track>
    <Extensions>
    <LX xmlns="www.garmin.com/.../v2">
    <MaxBikeCadence>102</MaxBikeCadence>
    </LX>
    <LX xmlns="www.garmin.com/.../v2">
    <AvgSpeed>6.810906062299742</AvgSpeed>
    </LX>
    </Extensions>
    </Lap><Lap StartTime="2012-05-26T13:11:14.000Z">
    <TotalTimeSeconds>767.53</TotalTimeSeconds>
    <DistanceMeters>4359.16</DistanceMeters>
    <MaximumSpeed>11.5174026</MaximumSpeed>
    <Calories>158</Calories>
    <AverageHeartRateBpm>
    <Value>116</Value>
    </AverageHeartRateBpm>
    <MaximumHeartRateBpm>
    <Value>144</Value>
    </MaximumHeartRateBpm>
    <Intensity>Active</Intensity>
    <Cadence>64</Cadence>
    <TriggerMethod>Manual</TriggerMethod>
    <Track>
    <Trackpoint>
    <Time>2012-05-26T13:11:14.000Z</Time>
    <AltitudeMeters>60.79999923706055</AltitudeMeters>
    <DistanceMeters>NaN</DistanceMeters>
    <HeartRateBpm>
    <Value>98</Value>
    </HeartRateBpm>
    <Cadence>0</Cadence>
    </Trackpoint>
    <Trackpoint>
    <Time>2012-05-26T13:11:15.000Z</Time>
    <AltitudeMeters>60.79999923706055</AltitudeMeters>
    <DistanceMeters>NaN</DistanceMeters>
    <HeartRateBpm>
    <Value>98</Value>
    </HeartRateBpm>
    <Cadence>0</Cadence>
    <Extensions>
    <TPX xmlns="www.garmin.com/.../v2">
    <Speed>0.0</Speed>
    </TPX>
    </Extensions>
    </Trackpoint>
    <Trackpoint>
    <Time>2012-05-26T13:11:16.000Z</Time>
    <AltitudeMeters>60.79999923706055</AltitudeMeters>
    <DistanceMeters>NaN</DistanceMeters>
    <HeartRateBpm>
    <Value>98</Value>
    </HeartRateBpm>
    <Cadence>0</Cadence>
    <Extensions>
    <TPX xmlns="www.garmin.com/.../v2">
    <Speed>0.0</Speed>
    </TPX>
    </Extensions>
    </Trackpoint>
  • Not able to combine files from two different Garmin 405s

    I am trying to combine files from two different Garmin 405s. We knew mine would run out of batteries and so we made a clean switch, splitting the ride into two sections between mine and my wife's 405s. The new file with both rides will not upload to Garmin "Upload Error". It did upload to Strava but only showed the first half of the ride. Anyone have any idea if it matters that the files are coming from 2 different 405'?
    Thanks
    Mark
  • Former Member
    0 Former Member over 12 years ago
    I am trying to combine files from two different Garmin 405s. We knew mine would run out of batteries and so we made a clean switch, splitting the ride into two sections between mine and my wife's 405s. The new file with both rides will not upload to Garmin "Upload Error". It did upload to Strava but only showed the first half of the ride. Anyone have any idea if it matters that the files are coming from 2 different 405'?
    Thanks
    Mark


    Hello Mark,

    The type of gps that made the files does not matter.
    Attach the 2 files you want to join to another post here. Zip them down first if they are big tcx files. Also attach the new file you made.

    I will try to explain what went wrong with your new file after I join the original 2.
  • Don,
    Thank you so much for your help. I have attached zipped files. I am able to upload the combined file to Strava but it only shows data from the first activity. Garmin connect tells me "an error occurred with your upload". Let me know what I'm doing wrong here.



    Thanks,

    Mark
  • Former Member
    0 Former Member over 12 years ago
    Don,
    Thank you so much for your help. I have attached zipped files. I am able to upload the combined file to Strava but it only shows data from the first activity. Garmin connect tells me "an error occurred with your upload". Let me know what I'm doing wrong here.



    Thanks,

    Mark


    Hello Mark,

    I joined the files and mine loads into Garmin Connect.

    The easiest way to see what you did wrong is to open my file in a text editor in one window next to your file opened in a second window, side by side.
    At the very beginning between <Activities> and <Track> are summary data, totals and averages for the ride. You needed to add the numbers from each separate file for <seconds> <meters> and <calories>. Pick the highest HR and Speed. The Avg HR is tougher, I use TopoFusion to get a better average as opposed to just adding and dividing by 2.

    Next do a Find for 16:21:02 that is where the 2 tracks are joined. You will see a space in my file there. Start comparing the 2 files there and you will see you put in </Track>. That stops everything unless it is followed by <Track>, which it is not, so it needs to be removed. That is the way XML files work.

    Then you added in a bunch of the summary data, right there, from file 2 that must be removed, you will see it. The rest is okay.....I think.

    Also, at the very bottom of the file is a line for the <AvgSpeed> for the entire ride. You correct that by going back to the top and getting the total <DistanceMeters> and divide it by <TotalTimeSeconds> and then hand enter in the new number.

    If you make yours look like mine it should load, Good Luck.
  • Hello Mark,

    I joined the files and mine loads into Garmin Connect.

    The easiest way to see what you did wrong is to open my file in a text editor in one window next to your file opened in a second window, side by side.
    At the very beginning between <Activities> and <Track> are summary data, totals and averages for the ride. You needed to add the numbers from each separate file for <seconds> <meters> and <calories>. Pick the highest HR and Speed. The Avg HR is tougher, I use TopoFusion to get a better average as opposed to just adding and dividing by 2.


    Thank you so much Don. It works perfectly.
    Great job describing the process for adjusting the files. I feel like I've got a good handle on it now.:)

    Mark
  • Former Member
    0 Former Member over 12 years ago
    TrailRunner seems to work really well for the task. I exported the files to TCX, imported them on Trail Runner, then used the button Append, exported the combined ride back out to a TCX activity.