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

81 Views Asked by At

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.

1

There are 1 best solutions below

0
David Specht On BEST ANSWER

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

var delimiter = csvReader.Context.Parser.Delimiter;