Search code examples
c#.netcsvhelper

When using CsvHelper with autodetected delimiter, how can you find the delimiter used?


Relates to CsvHelper - https://github.com/JoshClose/CsvHelper

We can use delimiter autodetection when reading a file, but after the reading is complete, is it possible to detect the delimiter used?

I've tried accessing csvReader.Configuration.Delimiter, but it returns the default comma even after reading a file that uses a pipe as the delimiter.


Solution

  • It looks like you can get the delimiter that was autodetected from the CsvParser.

    var delimiter = csvReader.Context.Parser.Delimiter;