npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@imlunahey/ahcd

v1.0.3

Published

Apple Health Care Data convert xml to csv

Readme

ahcd

Apple Health Care Data convert xml to csv

Introduction

This is a fork of the original ahcd project, with significant improvements:

  • Rewritten in TypeScript for better type safety and developer experience
  • Improved streaming XML parsing for better memory efficiency
  • Enhanced error handling and progress reporting
  • Better test coverage and CI integration
  • Modern build system and package structure

Features

  • Efficient streaming XML parsing for large health data exports
  • Memory-efficient processing with batch writing
  • Support for all Apple Health data types
  • Progress reporting during processing
  • Error handling for malformed XML
  • TypeScript support for developers

Installation

As a CLI tool

Install the command globally:

$ npm i -g @imlunahey/ahcd

As a library

Install as a dependency in your project:

$ npm i @imlunahey/ahcd

Usage

CLI Usage

$ npx @imlunahey/ahcd@latest export.xml
================================================================================
Apple Health Care Data convert xml to csv

Author     : luna (forked from Fumikazu Fujiwara) https://github.com/ImLunaHey
Homepage   : https://github.com/imlunahey/ahcd#readme
LICENSE    : MIT
Report bugs: https://github.com/imlunahey/ahcd/issues
================================================================================

Usage: ahcd [-h] <file> [-t <type>] [-d <dir>]
  • The < file > argument must be export.xml which I mentioned.
  • -t outputs only a specific csv (e.g. -t BodyMass)
  • -d specifies the directory to output to (e.g., -d /path/to)

Library Usage

import { AppleHealthCareData } from '@imlunahey/ahcd';
import { createReadStream } from 'fs';

async function processHealthData() {
  const ahcd = new AppleHealthCareData('./output');
  const xmlStream = createReadStream('export.xml');

  // Parse XML and write CSVs
  await ahcd.parseXml(xmlStream);
  ahcd.writeCsvs();

  // Get available data types
  const keys = ahcd.keys();
  console.log('Available data types:', keys);

  // Get CSV content for a specific type
  const heartRateCsv = ahcd.csv('HeartRate');
  console.log('Heart Rate data:', heartRateCsv);
}

Demo

$ npx @imlunahey/ahcd@latest -d . export.xml
Read export.xml
Analyze export.xml
Wrote . /Height.csv (1 records)
Wrote . /HeartRate.csv (87 records)
Wrote . /BodyMassIndex.csv (50 records)
Wrote . /BloodPressureDiastolic.csv (165 records)
Wrote . /BodyMass.csv (51 records)
Wrote . /BodyFatPercentage.csv (50 records)
Wrote . /FlightsClimbed.csv (1045 records)
Wrote . /BloodPressureSystolic.csv (165 records)
Wrote . /SleepAnalysis.csv (1193 records)
Wrote . /StepCount.csv (12032 records)
Wrote . /DistanceWalkingRunning.csv (13631 records)

Development

Building from source

# Clone the repository
git clone https://github.com/imlunahey/ahcd.git
cd ahcd

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

Contributing

Pull requests are welcome! Please ensure you:

  1. Add tests for new features
  2. Update documentation
  3. Follow the existing code style
  4. Run the test suite before submitting

License

MIT