export

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package export provides functions to export capture data to common file formats: CSV, Excel (.xlsx), SQLite, and WAV.

Each export function reads all remaining frames from a capture.Reader and writes them to the target format. The reader is consumed by the call; create a new reader for each export.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(w io.Writer, r *capture.Reader) error

CSV writes all remaining frames from r as CSV to w.

Capture metadata is written as # comment lines before the data. The first data column is the timestamp in seconds from the start of the capture, computed as frameIndex / sampleRate. Remaining columns are the calibrated channel values from capture.Frame.Values.

Column names are taken from capture.Channel.Name, falling back to "ch0", "ch1", etc. for unnamed channels.

func Excel

func Excel(path string, r *capture.Reader) error

Excel writes all remaining frames from r as an Excel .xlsx file at path.

The workbook contains two sheets:

  • "Data": timestamp_s column followed by one column per channel with calibrated values. Uses a streaming writer to handle large captures.
  • "Metadata": key-value pairs of capture metadata and properties.

Excel has a hard limit of 1,048,576 rows per sheet. Captures exceeding this limit will be truncated.

func SQLite

func SQLite(path string, r *capture.Reader) error

SQLite writes all remaining frames from r to a SQLite database at path.

Three tables are created:

metadata  — key-value pairs of capture metadata and properties.
channels  — one row per channel with index, type, range, name, and calibration.
frames    — one row per frame with timestamp_s and one column per channel.

Frame columns are named after the channels (see capture.Channel.Name), falling back to "ch0", "ch1", etc. Inserts are batched in transactions for performance.

func WAV

func WAV(w io.Writer, r *capture.Reader) error

WAV writes all remaining frames from r as a WAV audio file to w.

Each capture channel becomes one audio channel. Sample values are normalized to the [-1, +1] range and stored as 32-bit float PCM (IEEE 754). The WAV sample rate is taken from the capture header.

This format is useful for visualizing signals in audio editors such as Audacity. Non-analog channels (digital, counter, encoder) are included as-is, scaled to [-1, +1] by dividing by 262143 (the 18-bit ADC full-scale value).

WAV files have a 4 GiB size limit due to the 32-bit chunk size fields. For 8 channels at 100 kHz, this is roughly 22 minutes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL