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

batch change only of "uncategorized" activity

Hello I have old activities from my "old" Suunto ... all exported separately in FIT and TCX format. They are different type of activities.
When I import them, running activities are imported as "running" correctly. But other (hiking, fitness, etc.) are imported as uncategorized.
I have them separately, so I can import hiking separately etc.

I found python script to change activity type here:
https://forums.garmin.com/apps-software/mobile-apps-web/f/garmin-connect-web/165458/is-there-a-way-to-change-activity-category-in-a-large-batch/900064#900064

or directly https://pastebin.com/m48rwsae

In this script it changes all to biking.

I'm not python programmer, but from my knowledge I can change to different activity type than it is in the script.

But it changes ALL activities (from date to date). It is possible to change this script to "change only UNCATEGORIZED acitivities" instead of ALL acitivities?

Then I will import my hiking acitivities and change uncategorized to hiking.
After that I will import fitness and change uncategorized to correct type.

it is around 1900 activities for me and around 3600 activities for my brother's account

Top Replies

All Replies

  • Here you go: https://pastebin.com/jwWX1Hiz

    It's a new version of the script (now called gc-activity-type.py), which:

    1) Allows you to specify the new activity type (e.g. "cycling"), type ID (e.g. "2") and parent type ID (e.g. "17") on the command line (otherwise it will prompt you). Use the "--help" option to see command line options

    2) Allows you to filter/match activities by activity type (e.g. "uncategorized") and/or type ID, parent type ID.

    e.g.

    python3 gc-activity-type.py --match-activity-type uncategorized

    3) Has a --dry-run option so you can preview changes before applying them permanently

    4) Displays the activity type, type ID, and parent type ID for existing activities. (Use this with --dry-run to find out what values to use when applying changes.)

  • wow ... excellent, thank you very much for fast answer.

    now tested on few imported activities and works perfectly

  • No worries!

    I've updated the script so that it both displays and edits the parent type ID, since some activities have a different parent type ID than 17 (which is used for running and cycling.) (Cardio and strength have a parent type ID of 29).

    You can see the type name, type ID and parent type ID of existing activities by using the --dry-run option.

    https://pastebin.com/jwWX1Hiz

  • Hello WillNorthYork,

    Something has been changed, because I got this error message today when I was running your code :

    Traceback (most recent call last):
      File "C:\Program Files\Python\lib\idlelib\run.py", line 559, in runcode
        exec(code, self.locals)
      File "D:\SPORT ACTIVITIES DATA\Other\Sport devices & softwares\Garmin Connect\gc-activity-type.py", line 324, in <module>
        ACTIVITY_LIST = http_req(ACLISTURL)
      File "D:\SPORT ACTIVITIES DATA\Other\Sport devices & softwares\Garmin Connect\gc-activity-type.py", line 115, in http_req
        response = OPENER.open((request), data=post)
      File "C:\Program Files\Python\lib\urllib\request.py", line 531, in open
        response = meth(req, response)
      File "C:\Program Files\Python\lib\urllib\request.py", line 640, in http_response
        response = self.parent.error(
      File "C:\Program Files\Python\lib\urllib\request.py", line 569, in error
        return self._call_chain(*args)
      File "C:\Program Files\Python\lib\urllib\request.py", line 502, in _call_chain
        result = func(*args)
      File "C:\Program Files\Python\lib\urllib\request.py", line 649, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 402: Payment Required

    Is there any solutions?

    I found a thread as something working with this problem, but to be honest I dont understand whether it is the end of using this script or not: github.com/.../44

  • Forget it!

    I rolled up my sleeves and went through the manual activity type change.