Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arthurgousset/applehealth
π οΈ Converts XML health data to CSV
https://github.com/arthurgousset/applehealth
apple applehealth
Last synced: 18 days ago
JSON representation
π οΈ Converts XML health data to CSV
- Host: GitHub
- URL: https://github.com/arthurgousset/applehealth
- Owner: arthurgousset
- Created: 2024-02-04T11:00:32.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-04T12:21:56.000Z (10 months ago)
- Last Synced: 2024-10-14T01:10:34.674Z (about 1 month ago)
- Topics: apple, applehealth
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Apple Health Data Converter (`.xml` to `.csv`)
Convert XML health data from Apple's Health app to csv.
You can export health data from [Apple's Health app](https://www.apple.com/ios/health/).
Unfortunately, the exported health data comes in XML format.
This script reads the health data (in `.xml`) and produces a new file for you (in `.csv`).## Usage
```sh
# Clone the repository
$ git clone# Navigate to the project directory
$ cd applehealth# Install the dependencies
$ yarn install
```Copy the Apple Health file you exported (`export.xml`) to the project directory.
```sh
# Run the script
$ yarn ts-node convert.ts
```## How it works
The script reads the `export.xml` file and parses a subset of the records that match a filter.
I'm looking for records of type `HKQuantityTypeIdentifierBodyMass` (i.e. weight records):
```
```That means the script will only parse records of type `HKQuantityTypeIdentifierBodyMass` and convert them into a csv format. You can change the filter to match other types of records.
The script produces a new `weight.csv` file with two columns, "date", and "weight".
For each row in the csv:
- the `date` value is set to the `startDate` value from the XML record (in DD/MM/YYYY format),
- the `weight` value is set to the `value` value of the XML record in the same format.## How to export health data from Apple's Health app
Source: [Share your data in Health on iPhone](https://support.apple.com/en-gb/guide/iphone/iph5ede58c3d/ios)
> You can export all of your health and fitness data from Health in XML format, which is a common format for sharing data between apps.
>
> 1. Tap your picture or initials at the top right.
>
> If you donβt see your picture or initials, tap Summary or Browse at the bottom of the screen, then scroll to the top of the screen.
>
> 2. Tap Export All Health Data, then choose a method for sharing your data.