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

No units field for Apple FIT files #121

Open
wjkaufman opened this issue Jan 21, 2021 · 3 comments
Open

No units field for Apple FIT files #121

wjkaufman opened this issue Jan 21, 2021 · 3 comments

Comments

@wjkaufman
Copy link

wjkaufman commented Jan 21, 2021

I'm trying to parse a FIT file recorded by an Apple Watch, but I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-f31030851587> in <module>
----> 1 list(fit.get_messages())

~/opt/anaconda3/envs/body/lib/python3.8/site-packages/fitparse/base.py in get_messages(self, name, with_definitions, as_dict)
    432         # If there are unparsed messages, yield those too
    433         while not self._complete:
--> 434             message = self._parse_message()
    435             if message and should_yield(message):
    436                 yield message.as_dict() if as_dict else message

~/opt/anaconda3/envs/body/lib/python3.8/site-packages/fitparse/base.py in _parse_message(self)
    154                     add_dev_data_id(message)
    155                 elif message.mesg_type.name == 'field_description':
--> 156                     add_dev_field_description(message)
    157 
    158         self._messages.append(message)

~/opt/anaconda3/envs/body/lib/python3.8/site-packages/fitparse/records.py in add_dev_field_description(message)
    455     #     units = units.raw_value
    456     # original below
--> 457     units = message.get('units').raw_value
    458 
    459     native_field_num = message.get('native_field_num')

AttributeError: 'NoneType' object has no attribute 'raw_value'

As a potential solution I tried modifying add_dev_field_description to see if units is in the message (see below), and it seemed to resolve the issue:

global DEV_TYPES
dev_data_index = message.get('developer_data_index').raw_value
field_def_num = message.get('field_definition_number').raw_value
base_type_id = message.get('fit_base_type_id').raw_value
field_name = message.get('field_name').raw_value
# starting changes...
units = message.get('units')
if units is not None:
    units = units.raw_value
# ending changes; original below
# units = message.get('units').raw_value
...
@dtcooper
Copy link
Owner

Probably it's the outdated profile. Hmmm....

@dtcooper
Copy link
Owner

@wjkaufman could you provide us with a copy of a FIT file recorded by your Apple watch? (If you're not comfortable sharing it publicly, you could email me at [email protected] and I will keep it confidential.)

@evensolberg
Copy link

I'm the one who opened the issue mentioned by @fgebhart .. Feel free to use the FIT file I uploaded to his issue. It's from the Wahoo app on an iPhone.

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

No branches or pull requests

3 participants