qs_ledger icon indicating copy to clipboard operation
qs_ledger copied to clipboard

apple health: parse error after upgrading to iOS 16

Open aperiodicchain opened this issue 2 years ago • 3 comments

Upgrading to iOS 16 apparently also updated the HealthKit protocol: HealthKit Export Version: 11 to HealthKit Export Version: 12

Parsing export.xml now throughs a parse error:

File "/.../qs_ledger/apple_health/apple-health-data-parser.py", line 118, in __init__
    self.data = ElementTree.parse(f)
File "/home/usr/.pyenv/versions/3.10.4/lib/python3.10/xml/etree/ElementTree.py", line 1229, in parse
    tree.parse(source, parser)
File "/home/usr/.pyenv/versions/3.10.4/lib/python3.10/xml/etree/ElementTree.py", line 580, in parse
    self._root = parser._parse_whole(source)
**xml.etree.ElementTree.ParseError: syntax error: line 156, column 0**

The problem has already been reported and seems to be ignored by Apple: problem with import of XML Apple HealthKit Export Version: 12 Any thoughts on the suggested workaround with "patch.txt"?

aperiodicchain avatar Nov 19 '22 11:11 aperiodicchain

While waiting for a fix, I've been opening up the file in a text editor (BBEdit) and deleting the DTD portion of the file (first ~200 lines of the file) and haven't seen any downstream issues since, I believe, nothing is using that metadata.

StevenMMortimer avatar Dec 02 '22 15:12 StevenMMortimer

@aperiodicchain Thanks for pointing this out and posting an issue.

@StevenMMortimer Thanks for sharing a solution. I was able to follow your tip and I was able to run the notebooks by removing all of the lines between <?xml version ?> and <HealthData ..> like you see here:

Screen Shot 2023-01-06 at 15 40 09

This isn't a real fix but it does provide a workaround for anyone that gets stuck for now. These are admittedly use files to edit.

markwk avatar Jan 06 '23 23:01 markwk

@markwk I just got the latest iOS:, 16.2. Apple upgraded to <!-- HealthKit Export Version: 13 --> and the issue seems to be fixed, at least for me.

aperiodicchain avatar Jan 07 '23 06:01 aperiodicchain