CsvHelper
CsvHelper copied to clipboard
CsvReader.ColumnCount is not set
A comment on IReaderRow.ColumnCount says, "Gets the column count of the current row. This should match CsvHelper.IParser.Count." I'm finding on CsvReader that ColumnCount is zero even when CsvReader.Parser.Count has a correct value.
It looks like it's only set when DetectColumnCountChanges is true.
I have the same issue while calling csvReader.ColumnCount. This property name is confusing.
Agreed, this should be set on every record read. I don't want exception to be thrown on csvHelper.Read(), which occurs when DetectColumnCountChanges=true is set. Which short circuits my ability to deal with that bad record. So was figuring it would be set on every record read to determine if it matches my expected column count, but alas, it is not. So I can no longer handle bad records where the column count is incorrect :(
Well over a year old, but I just ran into this issue. My workaround (and correct me if this is incorrect) was to use csvReader.Parser.Count
Same here! It's confusicating.
Fixed.