fix(metadata,cli): drop unnamed columns so R-exported CSVs validate (#109)#112
Closed
Mandyx22 wants to merge 1 commit into
Closed
fix(metadata,cli): drop unnamed columns so R-exported CSVs validate (#109)#112Mandyx22 wants to merge 1 commit into
Mandyx22 wants to merge 1 commit into
Conversation
…109) R's write.csv(row.names=TRUE) prepends an unnamed row-index column, so the header starts with a bare comma (an empty-string column name). Such a column can't appear in variableMeasured (Psych-DS requires a name), so the library skipped it while warning once per row, and the CLI copied the CSV verbatim — leaving a column with no metadata and failing validation with CSV_COLUMN_MISSING_FROM_METADATA. generate() now strips empty/whitespace-only columns from parsed data up front with a single warning, via a new exported stripUnnamedColumns helper. The CLI re-serialises a .csv input that has unnamed columns (preserving column order) so the written file matches variableMeasured; well-formed CSVs are still copied byte-for-byte. Fixes finding #2 of #109. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 57b5bcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Jun 16, 2026
Contributor
Author
|
Superseded by #114 — finding #2 is re-cut on top of #103's shared |
jodeleeuw
pushed a commit
that referenced
this pull request
Jun 18, 2026
#109) R's write.csv(row.names=TRUE) prepends an unnamed row-index column (empty-string header). It can't appear in variableMeasured (Psych-DS requires a name), so generate() drops it from the metadata — but the on-disk CSV kept it, failing validation with CSV_COLUMN_MISSING_FROM_METADATA. Put the strip in the shared data-file path so the CLI and frontend behave identically (layered on #103's buildPsychDSDataFiles): - New exported stripUnnamedColumns helper; generate() strips parsed data up front with a single warning (keeps variableMeasured clean + standalone use safe). - buildPsychDSDataFiles strips the main table: a clean CSV keeps its exact bytes (verbatim mainContent), a dirty one is re-serialised from cleaned rows. - CLI (rename-plan + non-plan paths) and frontend now feed parsed mainRows, so the written/zipped/validated CSV always matches the metadata. Supersedes #112 and #113 (the CLI verbatim-write rewrite and the frontend-only normalizeData helper) with one shared-builder implementation. Fixes finding #2 of #109. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jodeleeuw
pushed a commit
that referenced
this pull request
Jun 18, 2026
#109) (#114) R's write.csv(row.names=TRUE) prepends an unnamed row-index column (empty-string header). It can't appear in variableMeasured (Psych-DS requires a name), so generate() drops it from the metadata — but the on-disk CSV kept it, failing validation with CSV_COLUMN_MISSING_FROM_METADATA. Put the strip in the shared data-file path so the CLI and frontend behave identically (layered on #103's buildPsychDSDataFiles): - New exported stripUnnamedColumns helper; generate() strips parsed data up front with a single warning (keeps variableMeasured clean + standalone use safe). - buildPsychDSDataFiles strips the main table: a clean CSV keeps its exact bytes (verbatim mainContent), a dirty one is re-serialised from cleaned rows. - CLI (rename-plan + non-plan paths) and frontend now feed parsed mainRows, so the written/zipped/validated CSV always matches the metadata. Supersedes #112 and #113 (the CLI verbatim-write rewrite and the frontend-only normalizeData helper) with one shared-builder implementation. Fixes finding #2 of #109. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes finding #2 of #109: a real jsPsych dataset exported from R fails Psych-DS validation because of an unnamed row-index column.
R's
write.csv(with the defaultrow.names = TRUE) prepends an unnamed row-index column, so the CSV header starts with a bare comma — an empty-string column name. Psych-DS variables require a name, so the column can never appear invariableMeasured. Previously:Name field is missing. Variable not added.once per row, andleaving a column in the file with no metadata entry and failing validation with
CSV_COLUMN_MISSING_FROM_METADATA.How
The library owns
variableMeasured; the CLI owns the on-disk CSV — so both must agree, or the file the validator reads won't match the metadata.stripUnnamedColumns(rows)— new exported helper in the metadata package that drops empty/whitespace-only-named columns in place and reports which were dropped.generate()strips unnamed columns from the parsed data up front, with a single warning instead of per-row spam..csvinput that contains unnamed columns (column order preserved) so the written file matchesvariableMeasured; well-formed CSVs are still copied byte-for-byte. Mirrored on the JSON→CSV conversion path too.Chose to drop the column (the issue's suggested option a) rather than synthesize a name — it's a meaningless row index, so dropping yields the least-surprising valid dataset.
Testing
,subject_id,trial_type,…tosubject_id,trial_type,…andCSV_COLUMN_MISSING_FROM_METADATAno longer appears. (The lone residualtime_elapsederror is finding Incorporating Psych-DS validator with the metadata module #1, addressed separately on fix(metadata): register jsPsych system variables lazily (#109) #110; this branch is offmain.)🤖 Generated with Claude Code