Skip to content

CSV fields made only of double quotes are read back wrong #1058

Closed

Description

@vtxe02023274

Description

A CSV field that holds nothing but double quotes is read back wrong. " comes back as an empty string and "" comes back as ". MiniExcel writes these values correctly ("""" and """"""), so its own export does not round-trip.

CsvReader.Split unescapes "" before it strips the enclosing quotes:

.Select(s => DoubleQuotesRegexImpl.Replace(s.Replace("\"\"", "\""), ""))

For """" the replace pairs the enclosing quote with the escaped one and leaves "", and the regex then strips both. Fields with any other character in them are fine, e.g. "a", a", "a round-trip.

var exporter = MiniExcelV2.Exporters.GetCsvExporter();
var importer = MiniExcelV2.Importers.GetCsvImporter();
exporter.Export("a.csv", new[] { new { v = "\"" }, new { v = "\"\"" } });
var rows = importer.Query("a.csv", hasHeaderRow: true).ToList();
// rows[0].v == "" and rows[1].v == "\""

Expected Behavior

rows[0].v == "\"" and rows[1].v == "\"\"", the values that were written.

Actual Behavior

"" and "\"".

Workarounds

Pass a custom CsvConfiguration.SplitFn.

Environment (please fill the following information):

  • MiniExcel Version: master (c7fb0bd)
  • .NET Version: net8.0, net10.0, net11.0
  • OS: Windows

Additional Context

I'll send a PR that strips the enclosing quotes first and then unescapes "", with a test.

Activity

  1. added a commit that references this issue on Nov 21, 2026
    17fc565
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions