Search code examples
csvhelper

CsvHelper custom delimiter


In earlier versions of CsvHelper, I could set the default delimiter like this:

using var csv = new CsvReader(reader, CultureInfo.CurrentCulture);
csv.Configuration.Delimiter = "~";

How do I do this same thing in the current version (version 22)?


Solution

  • After a bit of Googling, I found this post in the CsvHelper issues. So, in the context of my original question, the correct code is now:

    var config = new CsvConfiguration(CultureInfo.CurrentCulture) { Delimiter = "~" };
    using var csv = new CsvReader(reader, config);