Training guidance tools using the API

My advice:
Don’t copy paste but always use the Get Data function from Excell.
If you Get Data from a csv (regardless if it comes from manual download or from a curl query) the first line of the csv states the column names. Use promote Headers to automatically set the column names from the first line and anything done afterwards is referenced to the column names. The position in the csv or the excel file doesn’t matter.
A second advantage of using Get Data is that you can specify the origin of the file (in this case it’s en-US, iso 65001 UTF8). The csv from download or curl has all data formatted as txt with decimal numbers using a dot as separator. If you copy paste a decimal number formatted as text in an Excell cell that is formatted as a decimal number, the result depends on your regional setting. If you are in a region using a decimal dot, it will be OK. If you are in a region using a comma, the dot will be interpreted as a thousand separator and if your regional setting is set to not showing the thousand separator, the dot simply is omitted and you loose the decimals…
Specifying the origin makes sure that if you change the columns format in Excel to a number or a date that the decimal dot is interpreted correctly (changed to a ‘,’ for EUR region for example) and also dates will be displayed correctly as set in your regional settings.
I’m pretty new to this stuff too but once you understand how it works, it makes it very easy to import data correctly.
The Transform script in my API_tools Excell file is now quite mature. Open a copy of it and edit the source to point to your csv file iso of the web api. Then in the Power Query advanced editor, remove any pointer to a column that isn’t present and it should work. It may take a bit of time before you understand what is happening, but once you get it, you will be able transform just about any file with dates and numbers from whatever region.
I should find an easy way of telling the Query editor, that it should only set column format for columns that exist. Most of the errors reported until now were caused by the script trying to set a format on a column that was not present.

I just got an idea. What if i prepared a second basic file that only gets the needed Wellness data from a local file (downloaded wellness.csv) and formats that data correctly? This file would not have the full blown functionality of the original file but only a tab for the iThlete HRV. Activity data will not be in the final file, it would only serve to show the iThlete chart.That should considerably reduce errors related to importing data and would need minimal change of configuration to use on Mac.
It would just need you to enter the file path to your downloaded file.
Did some quick testing and it shouldn’t be to difficult to make such a file. It will need a logic to disregard the first empty lines in the csv because the downloaded csv file has some empty projected days causing the chart to be blank for that number of days. Simple solution would be to auto populate the date field with today’s date.

Hello,
Is it possible to import totals (training zones) only into excel?
I tried to find the API but didn’t find…

Thank you very much

Found this as an endpoint in the swagger docs:

SummaryWithCats{
count	integer($int32)
time	integer($int32)
moving_time	integer($int32)
elapsed_time	integer($int32)
calories	integer($int32)
total_elevation_gain	number($float)
training_load	integer($int32)
srpe	integer($int32)
distance	number($float)
date	string
athlete_id	string
athlete_name	string
email	string
external_id	string
fitness	number($float)
fatigue	number($float)
form	number($float)
rampRate	number($float)
timeInZones	[...]
timeInZonesTot	integer($int32)
byCategory	[...]
mostRecentWellnessId	string
}

Thank you very much!
I’ll let you know :pray:t3:

The full featured file just got updated to version 1.5.
Changes:
1.5 ----- Accepts blank values for RHR and/or HRV while keeping correct averages. If too much data is missing, a watermark is indicated over the chart. That’s if more then 2 days out of the last 7 are missing or more then 9 out of the last 28. You will still get results but be notified by the watermark.

I will update the ‘Simple’ version later today.

Link is still:
Intervals_API_Tools – Google Drive

2 Likes

Just headup. I downloaded the file today , follow the instructions and looks good so far.
O little bit confunsing , abour workbook and updated workbook, which one i need to do the changes , but i think i do the right way.

Thanks so much

PS. if was possible how i can import just the sheet of IiThlete HRV , to another workbook and make work when “Refresh All” , without need to import others sheets ( i already have a bulk worbook, with a Dashboard , and graphs with my HRV , Tonnage , Volume , Food etc… )

Stumbled across and edge case today (and running the MacOS version, which I haven’t updated in a while so it may be fixed or irrelevant to others), which may be less relevant in the Northern Hemisphere winter/off-season.
The activities for 1Jan23, were being processed as 2023-01, as the logic in they YEAR() and ISOWEEK() functions are based on different things, found a good explanation about ISOWEEK()s first Thursday of the year start, and how to code for year here excel - week number and year combination - Stack Overflow

And the resulting code if anyone else needs/want it is swapping Activities “A”
is swapping
IF(B2="","",IF(ISOWEEKNUM(C2)<10,YEAR(C2)&"-0"&ISOWEEKNUM(C2),YEAR(C2)&"-"&ISOWEEKNUM(C2)))
with
=IF(B2="","",IF(ISOWEEKNUM(C2)<10,YEAR(C2+3-WEEKDAY(C2,3))&"-0"&ISOWEEKNUM(C2),YEAR(C2+3-WEEKDAY(C2,3))&"-"&ISOWEEKNUM(C2)))
2023-04

I really love the way WeekNum is used in this simplifies date/week handling so much, but the edge case caught me out.
Next fun, this year is one of the rarities that has 53 (iso)weeks…

Thanks for that. The weeknum function is my contribution to some of the work done on the various Excel files. My workaround (on my version) uses the IF function; when the week number is greater than 52, the new year and week 01 is then used.

As the HRV data is now managed using the app through MATLAB, the Excel file support has all but ended.

I still use the Excel file, but as mine works, I haven’t been look to improve on it.

Sorry, I typo’d my original.
The IF idea failed for me because 1Jan2023, showed up as 2023-52 originally, it’s in the second half of the 52nd week, but of 2022 calendar, so since week and year come from different maths, edge cases are tricky…

Just putting it here for reference, in case anyone else comes across similar.

The formula I use, is as follows:
=IF(G25="","",IF(YEAR(A25)<>YEAR(A26),YEAR(A26)&"-"&ISOWEEKNUM(activities[@[start_date_local]]),IFERROR(IF(activities[@[start_date_local]]="","",IF(C25<10,YEAR(activities[@[start_date_local]])&"-0"&C25,YEAR(activities[@[start_date_local]])&"-"&C25)),"")))

I need to give a public shout-out to @William_Barnes for the work he has put into the spreadsheet
“[Next Activity_icu v1 (shared)”. I’ve been using it for a month or so and going by its recommendations for “Next Activity” and I’ve been able to set many personal record wattage versus time numbers. The Next Activity workouts give me a choice on what I want to do the next day e.g.: FTP TTE, or CP TTE, or VO2Max, or just Z2.

Top shelf stuff.

Thanks @William_Barnes

3 Likes

Thanks @Kapooya_Bam!

Since I don’t think it’s earlier in this thread, here’s a stable link to the folder where the latest version (v2.3 currently) can be copied from for anyone else interested.

https://drive.google.com/drive/folders/111ji2LYKzKAPIPHKXvpdpxrLlE_f-vNI

4 Likes

Copied the file in the link from (Training guidance tools using the API - #22 by Gerald) in google sheets, entered the info, and ran the import data script, but getting an error message saying " Exception: Request failed for https://intervals.icu returned code 403. Truncated server response: {“status”:403,“error”:“Access denied”}"

Any suggestions?

I suggest you first try a more recent version and see if you still get the error - use the link in my post just above yours.

(reposted as a direct reply)

Hi all,
I’ve been using Excel version of Intervals_API_Tools_Office365_v1.6 but the data stopped refreshing at the end of March 2024. Excel throws [Expression error] The column “rampRate” of the table wasn’t found. Has anybody had the same issue? How can it be fixed?

Here’s a temporary quickfix:

I’m working on it and will share new version soon.

3 Likes

thanks for this! I did search for the issue on the forum but didn’t find the thread you referred to. I can confirm that simply removing "Columns=38, " from the source query step in v1.6 solves the issue.

1 Like

I tried the xlsx sheet today (recent version 1.6). I do not get the popup to enter the API key and PW.
grafik

I followed instructions mentioned in the readme (at least I think I did). Entered my ID and so on. I always get this error:
grafik

Did the data refresh. I entered the api and the password as shown in the screenshot above. Still the same error.
Any suggestions?

Let’s take this step by step:

  • Open a fresh copy of the sheet (don’t try to open the shared one! - download your own copy first)
  • Dismiss the two errors
  • Enter your AthleteID in the highlighted cell and quit the cell to make sure the ID is saved
  • Then goto Data menu and hit refresh
  • The Web Access dialog should now display

Are you using Microsoft Excel 2013 or newer on Windows or do you have another config? This sheet is not working on iOS/Mac.

1 Like