Skip to content

Split CSV rows only on the configured separator, not on tabs - #1046

Open
jayhemnani9910 wants to merge 1 commit into
mini-software:masterfrom
jayhemnani9910:fix/csv-split-only-on-separator
Open

jayhemnani9910 wants to merge 1 commit into
mini-software:masterfrom
jayhemnani9910:fix/csv-split-only-on-separator

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The CSV reader splits rows on a tab as well as on the configured separator. A comma-separated file with a tab inside a value then gets an extra field:

Name,Note,Qty
A,hello,1
B,col1<TAB>col2,2

Query(path, useHeaderRow: true) throws KeyNotFoundException: The given key '3' was not present in the dictionary., and without a header row the second line comes back with Qty in column D. SaveAs writes such a value without quotes, so MiniExcel can't read back its own CSV either.

The split pattern in CsvReader.Split was [\t{Seperator}].... It now uses only the configured separator, escaped. Files that use tabs as the separator need Seperator = '\t', as the docs and the existing tab test already do; before, they only worked by accident.

Added TabInsideValueIsNotASeparatorTest; it fails without the change. The CSV tests pass.

Summary by CodeRabbit

  • Bug Fixes
    • CSV imports now preserve tab characters inside fields when the configured separator is a comma. Values following those fields are also read correctly, so tabs within field content no longer cause the row to be split incorrectly. This improves the accuracy of imported data for comma-delimited files that contain tabs as part of their values.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CSV reader now treats only the configured separator as a field boundary. A new test checks that an embedded tab remains in a comma-delimited value and that the following field is read correctly.

Changes: CSV tab handling

Layer / File(s) Summary
Separator matching and tab preservation test
src/MiniExcel.Csv/CsvReader.cs, tests/MiniExcel.Csv.Tests/Main/MiniExcelCsvTests.cs
Split no longer treats tabs as unconditional separators. The test checks that Note retains an embedded tab and Qty reads as "2".

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: izanhzh, michelebastione

Merge Risk: Minimal · up to a4976

CSV fields containing tabs are now preserved when the separator is a comma. Files that use tabs as separators must set the separator explicitly. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: CSV rows are now split only on the configured separator instead of also on tabs. It matches the CsvReader.Split change and the new test in the summary and objectives.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5790cb0-0577-4f4e-8222-82aab749dbad
Commits

Reviewing files that changed from the base of the PR and between f390584 and a4976a2.

Files selected for processing: 2

  • src/MiniExcel.Csv/CsvReader.cs
  • tests/MiniExcel.Csv.Tests/Main/MiniExcelCsvTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant