sealed class CSVFileDefinitionMap : CsvClassMap<CSVFileDefinition>
{
public CSVFileDefinitionMap()
{
Map(m => m.FRM_ID).Name("FARM ID");
Map(m => m.FRM_OWNER).Name("FARM OWNER ");
}
}
class CSVFileDefinition
{
public string FRM_ID { get; set; }
public string FRM_OWNER { get; set; }
}
using (TextReader reader = File.OpenText(fileName)) {
var csv = new CsvReader(reader);
csv.Configuration.RegisterClassMap<CSVFileDefinitionMap>();
while (csv.Read()) {
var record = csv.GetRecord<CSVFileDefinition>();
}
}