8000 fix(cli): write one CSV column per value by draarivpatel-ui · Pull Request #1671 · meyda/meyda · GitHub
[go: up one dir, main page]

Skip to content

fix(cli): write one CSV column per value - #1671

Open
draarivpatel-ui wants to merge 1 commit into
meyda:mainfrom
draarivpatel-ui:fix/cli-csv-column-names
Open

draarivpatel-ui wants to merge 1 commit into
meyda:mainfrom
draarivpatel-ui:fix/cli-csv-column-names

Conversation

@draarivpatel-ui
Copy link
Copy Markdown

Summary

The CLI's CSV output had two problems that made the file hard to load:

  • The header had one name per feature, so values from multi-value features such as mfcc or amplitudeSpectrum had no column labels.
  • Multi-value features were followed by an extra comma, which left an empty field in every row and shifted the columns after it.

This is the problem described in #1048.

Change

  • The header now has one column per value. Nested values are expanded recursively, for example mfcc_0 to mfcc_12, amplitudeSpectrum_0, loudness_specific_0, loudness_total, complexSpectrum_real_0, complexSpectrum_imag_0.
  • Each row writes one value per column. The header and the rows use the same helper, so the names and values always line up.
  • Only bin/cli.js changes. JSON output and console output are unchanged.

Before and after

Command: node bin/cli.js tone.wav mfcc rms amplitudeSpectrum --o=out.csv, using a 0.5 s test tone at 22050 Hz.

  • Before: header mfcc,rms,amplitudeSpectrum (3 names). Each row has 272 fields, with an empty field after the 13 mfcc values.
  • After: header has 270 names. Every row has 270 fields.

Command: node bin/cli.js tone.wav loudness complexSpectrum --o=out.csv

  • Before: header has 4 names, rows have 1049 fields.
  • After: header has 1049 names. Every row has 1049 fields.

Tests: npx jest passes 112 of 112. eslint and prettier --check pass on bin/cli.js.

Not in this PR

Running spectralFlux alone crashes the CLI with dest.destroy is not a function. This also happens on the unmodified code. It is a separate problem and is not changed here.

Fixes #1048

The CSV writer had two problems:

- The header had one name per feature, so multi-value features such as
  mfcc, amplitudeSpectrum, loudness and complexSpectrum had no labels
  for their values.
- Multi-value features were followed by an extra comma, which left an
  empty column in every row and shifted the columns after it.

Nested values are now flattened recursively for both the header and
each row, so names look like mfcc_0, complexSpectrum_real_0 or
loudness_total, and every row has one value per column.

Fixes meyda#1048
Copilot AI balanced review requested due to automatic review settings November 9, 2026 02:37
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

All parameternames in csv output

2 participants

0