Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(health): adds float conversion #7

Closed
wants to merge 1 commit into from
Closed

fix(health): adds float conversion #7

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 1, 2020

Hello @simonkrenger,

Firstly thanks for this handy tool! This was exactly something I was looking for, for a long time..
I encountered the error below and adding float conversion for both calculations solved my problem.
Feel free to merge it, if you think this is the solution.
´´´
OK. Parsing files...
Traceback (most recent call last):
File "./health_to_fitbit.py", line 91, in
floors_dict[date_string] = int(floors_dict[date_string]) + int(value)
ValueError: invalid literal for int() with base 10: '19.5151'´
´´´

@simonkrenger
Copy link
Owner

simonkrenger commented Jul 3, 2020

Hi @drfrontend1

Thanks a lot for your contribution, that is much appreciated!

There were already multiple issues for the exact same issue (see #5 and #1 for example). It seems that different applications record the floor data differently, which leads to all these parsing errors. Interestingly, my own Apple Health exports do not include any floating point data (such as "19.5151" in your case), that makes it difficult to test.

Your commit looks very good and I am inclined to merge your fix, however I would be very interested to see what your data looks like. Could you add an example entry for one of your HKQuantityTypeIdentifierFlightsClimbed entries from your Apple Health Export?

That will help me in also creating proper tests (see #6) to catch all these different formats.

@ghost
Copy link
Author

ghost commented Jul 3, 2020

Hi @simonkrenger again,

Here you go with some sample data.

I've found the problematic record and I think I understand the reason behind it. Those floating values in this particular case comes from 'Garmin Connect' app and not directly from 'Apple Health'. Maybe it would be better to put an if case in the algorithm to take only values from 'Apple' devices into consideration while parsing it. That would make more sense. And of course, then we don't need to convert values to float first. What do you think?

´´´xml

<Record type="HKQuantityTypeIdentifierFlightsClimbed" sourceName="iPhone 7" sourceVersion="12.4.1" value="3"/>
<Record type="HKQuantityTypeIdentifierFlightsClimbed" sourceName="Connect" sourceVersion="1" unit="count" value="19.5151"/>
´´´

This was referenced Dec 3, 2021
@simonkrenger
Copy link
Owner

Closing this pull request as #10 should already fix this issue.

Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant