Chris wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file. Are their any offline tools for reading
the file and export to a more sensible format? I could write my own,
but I can't be the only one who wants to do this. Had a google and
couldn't find anything obvious.
I've seen the HealthView app and others but they either don't do what
I want or cost quite a lot of money to just export the data. Hence
the request for an offline tool.
Thanks!
I think Microsoft Edge is able to display XML in a way which is human readble.
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a more
sensible format? I could write my own, but I can't be the only one who
wants to do this. Had a google and couldn't find anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem to
parse the XML, and it was relatively easy to grab the records I wanted.
The relevant methods are:
---
def parse_apple_health_xml_file(filepath)
document = nil
contents = IO.read(filepath, chomp: false)
begin
document = Nokogiri::XML(contents)
rescue StandardError => exception
puts "ERROR: Could not parse #{filename} due to exception: #{exception.message}"
end
document
end
def get_blood_pressure_records(document)
records = Array.new
nodes = document.xpath("//HealthData/Record[contains(@type,'BloodPressure')]")
nodes.each_with_index do |node, index|
type = node['type'][/HKQuantityTypeIdentifierBloodPressure(Diastolic|Systolic)/, 1]
unit = node['unit']
date = node['creationDate']
value = node['value']
existing_record = records.select {|r| r[:date] == date}.first
if existing_record.nil?
record = {:date => date, :unit => unit, type.downcase.to_sym => value}
records << record
else
existing_record[type.downcase.to_sym] = value
end
end
records.sort_by!{|r| r[:date]}
end
---
The resulting records array of hashes look like this:
---
[
...
[44] {
:date => "2022-09-07 09:15:40 -0700",
:unit => "mmHg",
:systolic => "120",
:diastolic => "88"
},
[45] {
:date => "2022-09-08 10:31:27 -0700",
:unit => "mmHg",
:systolic => "129",
:diastolic => "87"
},
[46] {
:date => "2022-09-09 10:01:00 -0700",
:unit => "mmHg",
:systolic => "122",
:diastolic => "86"
}
]
---
So you can print out:
---
2022-09-07 09:15:40 -0700: S: 120 mmHg D: 88 mmHg
2022-09-08 10:31:27 -0700: S: 129 mmHg D: 87 mmHg
2022-09-09 10:01:00 -0700: S: 122 mmHg D: 86 mmHg
---
Pretty simple, really. Just change the XPath to get whatever you want,
and collect the information in a records array that suits your needs.
Jolly Roger <jollyroger@pobox.com> wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a more
sensible format? I could write my own, but I can't be the only one who
wants to do this. Had a google and couldn't find anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem to
parse the XML, and it was relatively easy to grab the records I wanted.
The relevant methods are:
(snip)
Pretty simple, really. Just change the XPath to get whatever you want,
and collect the information in a records array that suits your needs.
Thanks. That's really useful. Should be able to get a python script to do something similar. I just don't have the time at the moment and need to
drop off my bp readings at the GP.
This should be easier than having to write your own code.
badgolferman <REMOVETHISbadgolferman@gmail.com> wrote:
Chris wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file. Are their any offline tools for reading
the file and export to a more sensible format? I could write my own,
but I can't be the only one who wants to do this. Had a google and
couldn't find anything obvious.
I've seen the HealthView app and others but they either don't do what
I want or cost quite a lot of money to just export the data. Hence
the request for an offline tool.
Thanks!
I think Microsoft Edge is able to display XML in a way which is human
readble.
Firefox can too, but not this file.
On 15/11/2022 20:45, Jolly Roger wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
Jolly Roger <jollyroger@pobox.com> wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a
more sensible format? I could write my own, but I can't be the
only one who wants to do this. Had a google and couldn't find
anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem
to parse the XML, and it was relatively easy to grab the records I
wanted. The relevant methods are:
(snip)
Pretty simple, really. Just change the XPath to get whatever you
want, and collect the information in a records array that suits
your needs.
Thanks. That's really useful. Should be able to get a python script
to do something similar. I just don't have the time at the moment
and need to drop off my bp readings at the GP.
This should be easier than having to write your own code.
I suppose there's a small opportunity for someone to create an app to
parse the data and export it as CSV/whatever. I'm just not sure how
many people would be willing to purchase it.
It doesn't have to be an app. I'm more than happy with some code on
github. As I'm sure many others would be.
I just don't have the time at the moment and need to drop off my bp
readings at the GP.
This should be easier than having to write your own code.
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I just don't have the time at the moment and need to drop off my bp
readings at the GP.
This should be easier than having to write your own code.
You may be able to share your data with your GP this way instead:
<https://support.apple.com/en-us/HT213359>
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
Jolly Roger <jollyroger@pobox.com> wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a more
sensible format? I could write my own, but I can't be the only one who >>>> wants to do this. Had a google and couldn't find anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem to
parse the XML, and it was relatively easy to grab the records I wanted.
The relevant methods are:
(snip)
Pretty simple, really. Just change the XPath to get whatever you want,
and collect the information in a records array that suits your needs.
Thanks. That's really useful. Should be able to get a python script to do
something similar. I just don't have the time at the moment and need to
drop off my bp readings at the GP.
This should be easier than having to write your own code.
I suppose there's a small opportunity for someone to create an app to
parse the data and export it as CSV/whatever. I'm just not sure how many people would be willing to purchase it.
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I just don't have the time at the moment and need to drop off my bp
readings at the GP.
This should be easier than having to write your own code.
You may be able to share your data with your GP this way instead:
<https://support.apple.com/en-us/HT213359>
On 15/11/2022 20:45, Jolly Roger wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
Jolly Roger <jollyroger@pobox.com> wrote:I suppose there's a small opportunity for someone to create an app
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a more >>>>> sensible format? I could write my own, but I can't be the only one who >>>>> wants to do this. Had a google and couldn't find anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem to >>>> parse the XML, and it was relatively easy to grab the records I wanted. >>>> The relevant methods are:
(snip)
Pretty simple, really. Just change the XPath to get whatever you want, >>>> and collect the information in a records array that suits your needs.
Thanks. That's really useful. Should be able to get a python script to do >>> something similar. I just don't have the time at the moment and need to
drop off my bp readings at the GP.
This should be easier than having to write your own code.
to
parse the data and export it as CSV/whatever. I'm just not sure how many
people would be willing to purchase it.
It doesn't have to be an app. I'm more than happy with some code on
github. As I'm sure many others would be.
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
On 15/11/2022 20:45, Jolly Roger wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
Jolly Roger <jollyroger@pobox.com> wrote:
On 2022-11-15, Chris <ithinkiam@gmail.com> wrote:
I've exported my health data from the Health App, but it's in a
horribly mangled XML file.
The XML isn't mangled - it's completely valid XML. ; )
Are their any offline tools for reading the file and export to a
more sensible format? I could write my own, but I can't be the
only one who wants to do this. Had a google and couldn't find
anything obvious.
I did just that (wrote my own) earlier this year to grab my blood
pressure records from it. I wrote it in Ruby using the nokogiri gem
to parse the XML, and it was relatively easy to grab the records I
wanted. The relevant methods are:
(snip)
Pretty simple, really. Just change the XPath to get whatever you
want, and collect the information in a records array that suits
your needs.
Thanks. That's really useful. Should be able to get a python script
to do something similar. I just don't have the time at the moment
and need to drop off my bp readings at the GP.
This should be easier than having to write your own code.
I suppose there's a small opportunity for someone to create an app to
parse the data and export it as CSV/whatever. I'm just not sure how
many people would be willing to purchase it.
It doesn't have to be an app. I'm more than happy with some code on
github. As I'm sure many others would be.
Have you looked? I just did a search on GitHub for "apple health" and
see a few hits.
I came across exactly this - I wanted to track my weight in a
spreadsheet - had been adding it into the phone daily. The XML was
quite horrible
I'm not sure why you guys think anything is wrong with the XML. It's completely valid and easily parsed...
On 15 Nov 2022 at 17:56:57 GMT, "Jolly Roger" <jollyroger@pobox.com> wrote:
I came across exactly this - I wanted to track my weight in a
spreadsheet - had been adding it into the phone daily. The XML was
quite horrible
I'm not sure why you guys think anything is wrong with the XML. It's
completely valid and easily parsed...
Ok let's be clearer - no suggestion that the XML was not valid but was
not in a format that could be easily (as far as I could see) into a
typical end user app such as Excel - I wanted just two data items
(date & weight - note that the data items don't always have to rhyme)
and in the absence of knowledge of any other tools, took an approach
that I knew I could make work (was only to be a one-off).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 40:30:24 |
Calls: | 10,392 |
Files: | 14,064 |
Messages: | 6,417,205 |