CsvHelper gets only the title bar

I am trying to read the downloaded CSV file and before doing anything with the data that I need to check for the first header name to make sure that it is the correct file. I am trying to find a way to do this, but the reader goes to the second line. Is there a direct way to select one of the headers and check its value?

+7
csvhelper
source share
1 answer

You can use the parser directly if you just want to check the first line.

var parser = new CsvParser( textReader ); var row = parser.Read(); if( row[0] == "MyColumn" ) { /* do something */ } 

If you use Stream , you will need to reset at the beginning if you intend to use it again.

+8
source share

All Articles