No units field for Apple FIT files
wjkaufman opened this issue · comments
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
...
Probably it's the outdated profile. Hmmm....
@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 david@dtcooper.com and I will keep it confidential.)
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.