简体   繁体   中英

Index matching from CsvHelper doesn't work

I use CSVHelper version 3 Beta 6:

CustomCsvMapping class:

public class FoobarCsvMapping : CsvClassMap<FooImportModel>
{
        public FoobarCsvMapping ()
        {
            Map(x => x.Foo).Index(0);
            ...
        }
}

And I configurate this custom mapping class by calling:

 reader.Configuration.RegisterClassMap(new FoobarCsvMapping());

Structure of my testCsv file (1 line includes the header):

OtherHeaderPropertyName;...
0;...

If I read my csv-file, I always get the exception of type CsvMissingFieldException with this message:

Fields 'Foo' do not exist in the CSV file.

I don't care about the header names in the csv-file, I want an index matching...

Thank you in advance

CsvReader.Configuration.HasHeaderRecord = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM