i've just started having a similar issue and can't figure out why when i read my file, this is my map:
Map(s => s.SPID).Name("SPID").Index(0);
Map(s => s.WholesalerID).Name("Wholesaler ID").Index(1);
Map(s => s.RetailerID).Name("Retailer ID").Index(2);
Map(s => s.OtherWholesalerID).Name("Other Wholesaler ID").Index(3);
Map(s => s.MultipleWholesalersFlag).Name("Multiple Wholesalers Flag").Index(4);
Map(s => s.DisconnectionStatus).Name("Disconnection Status").Index(5);
Map(s => s.VOABAReference).Name("VOA BA Reference").Index(6);
Map(s => s.VOABAReferenceReasonCode).Name("VOA BA Reference Reason Code").Index(7);
Map(s => s.UPRN).Name("UPRN").Index(8);
Map(s => s.UPRNReasonCode).Name("UPRN Reason Code").Index(9);
Map(s => s.CustomerClassificationSensitiveCustomer).Name("Customer Classification - Sensitive Customer").Index(10);
Map(s => s.PublicHealthRelatedSiteSpecificArrangementsFlag).Name("Public Health Related Site Specific Arrangements Flag").Index(11);
Map(s => s.NonPublicHealthRelatedSiteSpecificArrangementsFlag).Name("Non-Public Health Related Site Specific Arrangements Flag").Index(12);
Map(s => s.NonPublicHealthRelatedSiteSpecificArrangementsFreeDescriptor).Name("Non-Public Health Related Site Specific Arrangements Free Descriptor").Index(13).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Non-Public Health Related Site Specific Arrangements Free Descriptor")));
Map(s => s.StandardIndustrialClassificationCode).Name("Standard Industrial Classification Code").Index(14);
Map(s => s.StandardIndustrialClassificationCodeType).Name("Standard Industrial Classification Code Type").Index(15);
Map(s => s.RateableValue).Name("Rateable Value").Index(16);
Map(s => s.OccupancyStatus).Name("Occupancy Status").Index(17);
Map(s => s.BuildingWaterStatus).Name("Building Water Status").Index(18);
Map(s => s.LandlordSPID).Name("Landlord SPID").Index(19);
Map(s => s.Section154ADwellingUnits).Name("Section 154A Dwelling Units").Index(20);
Map(s => s.CustomerName).Name("Customer Name").Index(21).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Customer Name")));
Map(s => s.CustomerBannerName).Name("Customer Banner Name").Index(22).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Customer Banner Name")));
Map(s => s.Address.FreeDescriptor).Name("Premises Address – Free Descriptor").Index(23).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Free Descriptor")));
Map(s => s.Address.SecondaryAddressableObject).Name("Premises Address – Secondary Addressable Object").Index(24).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Secondary Addressable Object")));
Map(s => s.Address.PrimaryAddressableObject).Name("Premises Address – Primary Addressable Object").Index(25).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Primary Addressable Object")));
Map(s => s.Address.AddressLine1).Name("Premises Address – Address Line 1").Index(26).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Address Line 1")));
Map(s => s.Address.AddressLine2).Name("Premises Address – Address Line 2").Index(27).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Address Line 2")));
Map(s => s.Address.AddressLine3).Name("Premises Address – Address Line 3").Index(28).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Address Line 3")));
Map(s => s.Address.AddressLine4).Name("Premises Address – Address Line 4").Index(29).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Address Line 4")));
Map(s => s.Address.AddressLine5).Name("Premises Address – Address Line 5").Index(30).ConvertUsing(r => BaseFileParser.RemoveLineBreaks(r.GetField<string>("Premises Address – Address Line 5")));
Map(s => s.Address.Postcode).Name("Premises Address - Postcode").Index(31);
Map(s => s.Address.PAFAddressKey).Name("Premises Address – PAF Address Key").Index(32);
Map(s => s.SupplyPointEffectiveFromDate).Name("Supply Point Effective From Date").Index(33).TypeConverterOption.Format("yyyy-MM-dd");
Map(s => s.RegistrationStartDate).Name("Registration Start Date").Index(34).TypeConverterOption.Format("yyyy-MM-dd");
Map(s => s.OtherServiceCategoryProvidedFlag).Name("Other Service Category Provided Flag").Index(35).TypeConverter<NullableBooleanTypeConverter>();
Map(s => s.OtherServiceCategoryProvidedFlagReason).Name("Other Service Category Provided Flag Reason").Index(36);
Map(s => s.VolumeTransferType).Name("Volume Transfer Type").Index(37);
Map(s => s.InterimDutySupplyPointFlag).Name("Interim Duty Supply Point Flag").Index(38).TypeConverter<NullableBooleanTypeConverter>();
it gives me this error on the first line of the file:
: 'Header matching ['Premises Address - Postcode'] names at index 0 was not found. If you are expecting some headers to be missing and want to ignore this validation, set the configuration HeaderValidated to null. You can also change the functionality to do something else, like logging the issue.'
here is the file it's failing on:
test-data.txt
and to process it i do this:
using (var textReader = File.OpenText(fullFilePath))
{
//skip the first line
textReader.ReadLine();
using (CsvHelper.CsvReader reader = new CsvHelper.CsvReader(textReader, config))
{
//reader.Read();
//var headres = reader.ReadHeader();
meters = reader.GetRecords<T>().ToList();
}
}
any idea why i would get this? in the exception detail i can see the record has the correct number of cells and they all line up where they should, the header also looks to be correct
i've just started having a similar issue and can't figure out why when i read my file, this is my map:
it gives me this error on the first line of the file: : 'Header matching ['Premises Address - Postcode'] names at index 0 was not found. If you are expecting some headers to be missing and want to ignore this validation, set the configuration HeaderValidated to null. You can also change the functionality to do something else, like logging the issue.'
here is the file it's failing on: test-data.txt
and to process it i do this:
any idea why i would get this? in the exception detail i can see the record has the correct number of cells and they all line up where they should, the header also looks to be correct
classes.txt