Export Google Fit Daily Steps, Weight and Distance to a Google Sheet

Updated on Friday, December 29, 2023

Comments Page 6

Return to post.

Comments

Gustavo

Hello Robert,

Thank you very much for all the help you provided.

I'm really dumb and I can't implement more data to get.

I took a look at the API Explorer link, but I didn't understand anything.

Is there any way to get all the data and put it in the columns, something more generic?

Thank you again

Ondra

Ahh, that's where:) I saw there were three values, but could not find where to change it in the script. Thanks again!

Robert Ellison

Hi Ondra, See https://developers.google.com/fit/datatypes/aggregate - it looks like weight has average, max and min. Try changing value[0] to value[2] when fetching the weight. The script is pulling data daily, if there isn't more than one measurement per day I'd imagine that all three would be the same.

Ondra

Hi Robert,

this is super useful, thank you!

Could you please help me just replace the the average weight with the minimum value for weight?I cannot seem to find that anywhere..

Thanks,

Ondra

Robert Ellison

Change the 1's in getMetricsForDays(1, 1, 'Metrics'); to 0's - that should pull today rather than yesterday. If this works change the script trigger to run more frequently.

Sarah Bayly

Thank you for your super quick response.

That works perfectly.

However is there any way to have it update more often rather than just once a day? Ideally once every 10 minutes?

Many thanks, Sarah

Robert Ellison

Hi Sarah, should be pretty easy. Instead of append row make a call like:

SpreadsheetApp.getActiveSheet().getRange('A1').setValue(steps);

Where A1 is the target cell. This will update rather than append. Sounds like a fun project. Good luck!

Sarah Bayly

This is great thank you.

I'm currently building a project (a remote control that only let's you watch YouTube if you've done enough daily steps :-) ) ... that needs the CURRENT DAILY STEP TOTAL.

Is there anyway for it to pull the steps say every 10 minutes (updating a cell rather than adding new lines)? I'm new to this, so have got it working, but don't know how to amend.

I'll make sure I share the finished project with you and link back here!

Many thanks. Sarah

Robert Ellison

James, the current script will store one set of credentials at a time. It's probably possible to create a multi-user version, or a multi-sheet implementation of what you're trying to do. It's not something I have time to do with this script though.

James Chambers

I am currently doing a study which monitors the steps of a group of diabetes patients. I would love to have all of their info into one spreadsheet. I already authorized my other google account via the option in the sheet by just logging in. Then I come to see 2 users in the oath user cap now. However I can only see data from the first user authorized. Do you have any repository to an idea like this ?

Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

Newsletter

Related

Average Server Response Time in Azure Metrics