Skip to main content

Convert WFDB ECG (.hea/.dat) to CSV with UNIX epoch nanosecond timestamps

Project description

HEA to CSV Converter

A Python package and CLI to convert WFDB ECG recordings (.HEA/.DAT) to CSV format with timestamped entries using UNIX epoch nanoseconds.

WFDB Format

The WFDB format consists of two files per recording:

  • .hea: Header file containing metadata about the recording (number of leads, sampling rate, start time, etc.)
  • .dat: Binary file containing the actual ECG signal samples.

For complete details, refer to WFDB Format Documentation.

Features

  • Converts all leads with precise timestamp for each sample (UNIX epoch in nanoseconds)
  • Handles multiple leads and variable durations
  • Progress bar for large datasets
  • Metadata printed and saved in JSON format (filename, leads, sampling rate, start time, etc.)
  • CLI support for direct command-line use
  • Output CSV includes time column as the first column (nanoseconds)

Installation

Install from PyPI:

pip install hea_to_csv

Usage

As a Python Module

from hea_to_csv import wfdb_to_csv

# Basic usage
wfdb_to_csv("recording.hea")  # Save as recording.csv

# With parameters
wfdb_to_csv(
    "recording.hea",
    output_file="example.csv",
    metadata_file="recording.json",
    verbose=True
)

CLI Usage

python -m hea_to_csv <input_file> [-o <output_file>] [-m <metadata_file>] [-q]

CLI Parameters

Argument Description
input_file Path to the input HEA file (required)
--output, -o <file_path> Optional output CSV file path (default: same as input file but with .csv)
--metadata, -m <file_path> Optional JSON metadata output path (default: same as input file but with .json)
--quiet, -q Suppress console output (default: False)

Change Log

v0.1.1

  • Change csv column name to Lead_{i}.csv

v0.1.0

  • Initial release
  • Converts HEA/DAT files to CSV with timestamp
  • Saves recording metadata in JSON format

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wfdb_to_csv-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wfdb_to_csv-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file wfdb_to_csv-0.1.1.tar.gz.

File metadata

  • Download URL: wfdb_to_csv-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for wfdb_to_csv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e96c4d6d527cb6be483edd19c4e7126be7816fde1a0165233e4146aa55fadbc9
MD5 09de09be651c4badb516cef53c9d3864
BLAKE2b-256 12bd1e3e18fc7652ff1657060d2b19281403f0ef7f0601e5beb45ce4d3503b98

See more details on using hashes here.

File details

Details for the file wfdb_to_csv-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wfdb_to_csv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for wfdb_to_csv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 465bd82b58d0ca8c6630c7cd2b277233bbd81a0cb39be669e2c7ba226f74043f
MD5 5c0c972938cbf5254581863ae8fe5747
BLAKE2b-256 a71ca538595d161b3bedf00bd1fc0945e180a409f3b7eea95f01e0a11608ed9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page