CsvHelper Parser.Read() not splitting columns

1.4k views Asked by At

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)

1

There are 1 answers

0
Chris Hehl On BEST ANSWER

Well, i feel stupid now...

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

Thanks Benjamin Podszun for getting me on the right track