fix(frontend/csvParser): accept single-column CSVs without a detectable delimiter#2
Merged
Merged
Conversation
…le delimiter
PapaParse appends a `Delimiter / UndetectableDelimiter` warning to
`results.errors` when the sample contains none of `,` `\t` `|` `;` (e.g.
a single-column CSV). The data still parses correctly using the default
`,` fallback, so the warning is informational. `parseCSV` was rejecting
on any non-empty `results.errors`, so a valid single-column CSV produced
the alert "Error parsing CSV file. Please ensure it is a valid CSV."
Filter that specific `{type, code}` pair out of the error array before
deciding whether to reject. All other PapaParse error codes
(`MissingQuotes`, `TooManyFields`, etc.) remain fatal.
Adds a unit test mirroring a real failing CSV (header + tickers, CRLF,
no delimiter chars). It fails on master, passes with the filter applied.
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.
Summary
A valid single-column CSV (no
,\t|;anywhere in the sample) was being rejected at upload with the alert "Error parsing CSV file. Please ensure it is a valid CSV." even though the data parsed correctly. This filters out PapaParse's informationalUndetectableDelimiterwarning before deciding whether to reject, so single-column CSVs work as expected.Changes
frontend/lib/csvParser.ts— filter{type: 'Delimiter', code: 'UndetectableDelimiter'}out of the error array before the reject check. All other PapaParse error codes (MissingQuotes,TooManyFields,InvalidQuotes, etc.) remain fatal and continue to surface to the user.frontend/__tests__/csvParser.test.ts— add a regression test mirroring a real failing file: header + values, CRLF line endings, no delimiter characters anywhere. The test fails onmasterand passes with the filter applied.Test plan
cd frontend && npm run lintcd frontend && npm run test— 41 passed (was 40; +1 new single-column test)cd backend && pytest tests/ -v— 56 passed (no regressions; backend untouched)Symbolheader + 33 tickers) end-to-end viadocker-compose -f docker-compose.local.yml up --build; column tag and data preview render, no alert.Versioning
Breaking changes
None. Multi-column CSVs are unaffected; only previously-rejected single-column CSVs now succeed.