问题
I have an exception thrown when loading this CSV file :/ which is quite simple :
public class BreederTemp
{
public BreederTemp ()
{
}
public int Id { get; set; }
public string Affix { get; set; }
public bool Affix_Prefix { get; set; }
}
public sealed class BreederClassMap : ClassMap<BreederTemp>
{
public BreederClassMap()
{
AutoMap();
Map(m => m.Id);
Map(m => m.Affix);
Map(m => m.Affix_Prefix);
}
}
class Program
{
static void Main(string[] args)
{
// [...]
System.IO.TextReader textReader = new StreamReader(CsvFile, Encoding.Default);
var csv = new CsvReader(textReader);
csv.Configuration.RegisterClassMap<BreederClassMap>();
csv.Configuration.Delimiter = ";";
csv.Configuration.Encoding = Encoding.Default;
csv.Read();
var packs = csv.GetRecords<BreederTemp>().ToList();
// Header matching [id] names exception
}
}
Here is the CSV test file I'm using. I tried to export from XLSS to CSV-UTF8 or CSV without any changes.
Id;Affix;Affix_Prefix
1;(sans affixe);0
2;Des garrigues du loup de canebas;0
3;De Dan Jourdain;0
Did I miss something ? thanks for help
来源:https://stackoverflow.com/questions/51582272/csvhelper-7-1-1-header-matching-id-names-at-index-0-was-not-found