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
timecolumn 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.0
- Initial release
- Converts HEA/DAT files to CSV with timestamp
- Saves recording metadata in JSON format
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wfdb_to_csv-0.1.0.tar.gz.
File metadata
- Download URL: wfdb_to_csv-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef0faeeeb2247e192c548f13f2ad04465773f1aa4e32e4252b1b31cebccb3f1d
|
|
| MD5 |
7d320e87664c2f1e195f064cc6a15173
|
|
| BLAKE2b-256 |
6386a7a6184644dfbe8c8beb1ecf7cf30b75e1cbeaf379c6a7dfcfcff3b87219
|
File details
Details for the file wfdb_to_csv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wfdb_to_csv-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a3fee687b5d184f594c5cf3568cd86eea35364f18727f89d193e11848c8f395
|
|
| MD5 |
b483524a47e09d7295a36d7c515e5e17
|
|
| BLAKE2b-256 |
fb3f521dc0e4096a61dcb75c70761076f4b4d29dd3279e139749db6dd039720a
|