CTHRU/Hitrava

[SUPPORT] Getting an error during JSON parsing KeyError 'attribute'

maxpontello opened this issue · 3 comments

Hello and thanks for you help in converting huawei health activities to other apps.
Just received my zipped file from huawei, extracted the JSON using password and tried converting it (only one actvity was inside).
Here is the command with output error (any idea about whta am i doing wrong?):

_**C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0>python hitrava.py --json hu.json --json_export
2020-12-20 18:59:32,829 - INFO - main - Hitrava version 4.0.0 (build 2010.2902) started with arguments ['--json', 'hu.json', '--json_export']
2020-12-20 18:59:32,829 - INFO - main - Running on Python version 3.9.1
2020-12-20 18:59:32,829 - INFO - parse - Found one or more activities in JSON at index 0 to parse from 2020-12-15 (YYY-MM-DD)
2020-12-20 18:59:32,829 - ERROR - parse - Error parsing JSON file <hu.json>
'attribute'
Traceback (most recent call last):
File "C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0\hitrava.py", line 1218, in parse
hi_activity = self._parse_activity(activity_dict)
File "C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0\hitrava.py", line 1238, in _parse_activity
hitrack_data = activity_dict['attribute']
KeyError: 'attribute'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0\hitrava.py", line 2041, in
main()
File "C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0\hitrava.py", line 2029, in main
hi_activity_list = hi_json.parse(args.from_date)
File "C:\Users\pontello\Desktop\huawei\Hitrava-4.0.0\hitrava.py", line 1233, in parse
raise Exception('Error parsing JSON file <%s>', self.json_file.name)
Exception: ('Error parsing JSON file <%s>', 'hu.json')**_

Thanks, Max

CTHRU commented

Not sure, the error hints to an unexpected content in the json file. For now, 2 possibilities

  1. You could check if you extracted the right json file from the Huawei ZIP file (there are multiple in different folders)
  2. Huawei might have changed the lay-out of the data in the json file. I requested my data and waiting for the export to become available to check.

Hello CTHRU, thanks for your answer. I've verified the files and you were right, probably i was taking the wrong json. Using the command to decrypt and convert the zip with password everything went fine.

Thanks so much for supporting me!

CTHRU commented

You're welcome, glad I could help.