Skip to content

joshualeond/gomat2csv

Repository files navigation

gomat2csv

CLI tool to convert MATLAB v5 .mat files to CSV.

Features

  • Auto-detects three common MATLAB data layouts
  • Converts MATLAB datenums to human-readable timestamps
  • Batch-processes entire directories of .mat files
  • Spinner UI for progress feedback
  • Combine multiple datasets into a single CSV

Installation

go install github.com/jduncan/gomat2csv@latest

Or build from source:

go build -o gomat2csv .

Usage

gomat2csv <file-or-dir> [file-or-dir...]

Flags

Flag Short Description
--output -o Output directory (default: same as input)
--combine -c Combine all datasets into a single CSV
--format -f Force format: table, cell, or auto (default: auto)
--list -l List datasets without converting
--version -v Print version

Examples

Convert a single file:

gomat2csv data/PL19.mat

Convert all .mat files in a directory:

gomat2csv data/SOC_40%-100%_HalfC/

List datasets without converting:

gomat2csv -l data/PL19.mat

Combine datasets into one CSV:

gomat2csv -c -o output/ data/PL19.mat

Supported Formats

gomat2csv auto-detects three MATLAB data layouts:

  1. Table Array — Files containing __function_workspace__ with an Nx3 cell array. Typically battery test data with MATLAB table objects embedded in workspace bytes.

  2. Cell-Numeric — Cell arrays whose children are numeric matrices (e.g., a 30x1 cell of 7201x5 matrices).

  3. Simple Numeric — Direct numeric arrays, grouped by matching row count into datasets.

Build & Test

go build -o gomat2csv .
go test -v

About

CLI tool to convert Matlab `.mat` to `.csv` converter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors