CsvReader icon indicating copy to clipboard operation
CsvReader copied to clipboard

GetFieldIndex returns -1 when setting custom columns and specifying hasHeaders = true

Open janis-veinbergs opened this issue 8 years ago • 2 comments

Given I use hasHeaders: true for CsvReader constructor and want to manually specify columns with correct types, _fieldHeaderIndexes doesn't get populated that results in broken GetFieldIndex method.

Because given hasHeaders = true the _fieldHeaderIndexes gets populated (line 1592) only when no Columns have been added before.

My workaround is to initialize CsvReader with hasHeaders: false and then use csv.ReadNextRecord() before while loop: while (csv.ReadNextRecord()) { ... }

janis-veinbergs avatar Jun 09 '17 10:06 janis-veinbergs

I just ran into this bug as well. Thanks for providing a workaround.

BrianVallelunga avatar Jun 23 '17 16:06 BrianVallelunga

@janis-veinbergs @BrianVallelunga Can you check the current code base, there are some fixes around this

phatcher avatar Jan 30 '18 09:01 phatcher