Search code examples
c#csvhelper

CsvHelper Parser.Read() not splitting columns


For some to me unknown reason the csvHelper.parser.read() method returns a string array with only one entry containing the entire row.

The csv-file looks like this:

Name;Vorname;Alter

Petersen;Peter;18

Heinzen;Heinz;19

The code is like this:

using (CsvReader reader = new CsvReader(new StreamReader(path, Encoding.Default)))
{
    String[] cells = reader.Parser.Read();
    // cells = {"Name;Vorname;Alter"} (length = 1)
}

What am I doing wrong, or how do I get it to output an array of strings with three entries?

Edit:

CsvHelper: https://joshclose.github.io/CsvHelper/

expected result:

cells = {"Name", "Vorname", "Alter"} (length = 3)


Solution

  • Well, i feel stupid now...

    Change the reader.Configuration.Delimiter = ";";

    Thanks Benjamin Podszun for getting me on the right track