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 11 years ago
    Worked great

    Thanks, worked great!
  • Former Member
    0 Former Member over 11 years ago
    Thanks for the combined activitiy program

    It took a little trial and error but with all of the posts it works fine.. Just hope they don't move or erase this page for the next time I have a problem and need to combine for a single activity. Thanks again
  • Former Member
    0 Former Member over 11 years ago
    Can anyone help me with this?
    I tried using the java app but seem to just get an error on every attempt.
    First i used Garmin Training Centre to export the 3 .fit files (from my edge 510) that i am trying to merge. i chose to export as .tcx files.
    Then i opened the java app and selected the first 2 .tcx files and clicked Convert.

    after about 10 seconds i get an error. the first 2 lines of which say this...
    SystemID: ; Line#: 20; Column#: -1
    net.sf.saxon.trans.XPathException: A sequence of more than one item is not allowed as the first argument of number()

    followed by a long list of code type stuff.

    where have i gone wrong with this?
    is there any other solution??
  • Former Member
    0 Former Member over 11 years ago
    Hello James,

    Put your 3 files in 1 folder and zip it down and attach it to another post here and someone will tell you what is wrong and combine them and then you can try it yourself and see if you get the same result.
  • Former Member
    0 Former Member over 11 years ago
    I just whipped up a quick and dirty Java program that is self contained and easy to execute.

    Make sure you have Java installed, then...

    Download this .jar file, and then double click it.

    CombineActivities.jar


    This is about the most useful simple thing I have found on the Internet in a while - thanks!
  • Hi,
    I've just tried the java tool to merge two activities... and it's simply perfect !!!

    It took me a while to understand that I had to copy the lines in a text file and name it with TCX extension, but now it works :)
    I accidently turned my watch off during an activity, and had 2 activity files, now it's just one.

    Thank you very much for that great tool !!
    Cyril
  • Oh, just ont thing though...
    The 2 original activities were : 18:31 + 33:01 and 3,57 + 6,10 km
    and the final merged activity is now : 51:54 and 6,10km
    The altitude gain and other data don't seem to be right. Though it seems right on the map...

    Does anybody have an idea on why they don't just add to each other ?
    Cheers,
    Cyril
  • Former Member
    0 Former Member over 11 years ago
    Hello Cyril,

    Attach your 2 original files and the merged file you made to another post and someone here will tell you what happened to your numbers.
  • Former Member
    0 Former Member over 11 years ago
    Hello Cyril,

    The problem was you forgot to check the starting times for each file and number them in increasing order by time.
    You have them reversed so the program merged them in reverse order.
    When the Garmin software encounters that kind of error it stops at the backwards jump in time ignoring the last part of the file.
    I have attached a correctly merged file using the Fit File Repair Tool.
    Each part is now a lap so there are 2 laps.

    Just for grins you could rename your 2 files and merge them again with that JAR tool and compare the results.
    I changed the time on mine by 3 seconds so both files will load into Garmin Connect for comparison if you care.

    Also the coords on your 210 file are way off any roads or paths on your route.
    It has you going thru buildings and down the center of that 8 lane freeway. ;)