Help with splitting text shortcut (old fitbit data to Apple Health)

Hello.

I try to import my old fitbit-data into Apple Health via Shortcuts-app.

The data is stored as plain text, like this (i change the separator to #, instead of ,):

13-06-2013#78,2#27,06#21,1
14-06-2013#78,17#27,05#21,228
15-06-2013#78,14#27,04#21,356
16-06-2013#78,12#27,03#21,484
17-06-2013#78,09#27,02#21,612
18-06-2013#78,06#27,01#21,74

After loading the file, i use ‘Repeat with Each’ - ‘Split Text / New Line’ and ‘Split Text’ with Custom Separator #. How do i access the different elements of a line (date, weight, bmi, fat)? If i use ‘Get Item from List’ - i got an error message if i use an Index higher than 1.

Then i can log the different elements of each line to the correct place in Apple Health.

Thanks for you suggestions. :+1:

You haven’t shared your shortcut, so it’s nigh on impossible to debug. Maybe this example will give you something to work with?

https://www.icloud.com/shortcuts/364c2cd9bc284912ad98571aee39fb77

Hope that helps.

3 Likes

You should split in lines first and then repeat with each line: example.

1 Like

@hoppel indicated they were already splitting by new line and custom separator. There’s something about their use of the Get List Item that’s in question, though I guess it could be around the nesting of splits/repeats that could be the underlying issue.

It was just a question, don’t shared my shortcut because it is a very basic one without function.

https://www.icloud.com/shortcuts/b5c0fdee777046bbb0758306a94fb58b

Thanks for your examples, i will lock into them.

@Hoppel, the “Get Item from List” action applies to the return value of the action immediately before it. In your shortcut you should get the split text every time you need to access a list item: fixed shortcut.

2 Likes

Thanks, so far the splitting works. :+1: Now i will work on the correct date-format for Apple Health, followed by trying splitting the real fitbit-export. I will keep you updated and share the shortcut if finished.

Here’s a workflow I made to generate basic stats from a CSV file - shows how to parse rows and columns.

https://www.icloud.com/shortcuts/05616c5c1feb430d944f09447d0a53be

1 Like

Here is my final (for now) Shortcut for importing body-data (weight and body-fat) from fitbit into Apple Health. Works fine for me, have imported several years of data.

Please read the comments inside the Shortcut (only export the body-values, use at your own risk…)

https://www.icloud.com/shortcuts/1a3a6b59797a45d295dc884ae05c551c

And just for fun :smiley: - nice to see how the data got imported - here the steps from fitbit