1

I am trying to use GenericParserAdapter to read a CSV file into DataTable. And ColumnName is returning an incorrect value.

var adapter = new GenericParsing.GenericParserAdapter(outputFile.PathName);
DataTable dt = adapter.GetDataTable();

dt.Columns[0].ColumnName returns "Column1" which is not the actual name of that column. Not sure what I am doing wrong here.

Enfyve
  • 916
  • 10
  • 22
Razkar
  • 539
  • 5
  • 26
  • Are you importing using Oledb? If so did you specify in the connection string that the data had header a header row? – jdweng Mar 12 '18 at 17:51

1 Answers1

1

Check out this:

reading a CSV into a Datatable without knowing the structure

it would appear that you need to set the parser FirstRowHasHeader = true

I am not sure if this can be done in your constructor, or if you will need to split

var adapter = new GenericParsing.GenericParserAdapter(outputFile.PathName);

Into multiple lines and define the parser attributes after instantiation.

user7396598
  • 1,269
  • 9
  • 6