{"action":"created","issue":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/1078","repository_url":"https://api.github.com/repos/JoshClose/CsvHelper","labels_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/1078/labels{/name}","comments_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/1078/comments","events_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/1078/events","html_url":"https://github.com/JoshClose/CsvHelper/issues/1078","id":342448957,"node_id":"MDU6SXNzdWUzNDI0NDg5NTc=","number":1078,"title":"Headers cannot start with a capital letter.","user":{"login":"ksmiller99","id":8518337,"node_id":"MDQ6VXNlcjg1MTgzMzc=","avatar_url":"https://avatars3.githubusercontent.com/u/8518337?v=4","gravatar_id":"","url":"https://api.github.com/users/ksmiller99","html_url":"https://github.com/ksmiller99","followers_url":"https://api.github.com/users/ksmiller99/followers","following_url":"https://api.github.com/users/ksmiller99/following{/other_user}","gists_url":"https://api.github.com/users/ksmiller99/gists{/gist_id}","starred_url":"https://api.github.com/users/ksmiller99/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksmiller99/subscriptions","organizations_url":"https://api.github.com/users/ksmiller99/orgs","repos_url":"https://api.github.com/users/ksmiller99/repos","events_url":"https://api.github.com/users/ksmiller99/events{/privacy}","received_events_url":"https://api.github.com/users/ksmiller99/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-18T18:50:49Z","updated_at":"2018-07-18T19:41:51Z","closed_at":null,"author_association":"NONE","body":"After using GetRecords, I get an exception that the header name was not found if the first letter of the property name is upper case.  Here is the code I'm using:\r\n\r\n```\r\nusing CsvHelper;\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.IO;\r\n\r\nnamespace CsvTest\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            var SettingsFileName = @\"c:\\temp\\test.csv\";\r\n            var list = new List<Person>();\r\n            list.Add(new Person(\"Kevin\", DateTime.Now));\r\n            list.Add(new Person(\"Angela\", DateTime.Now));\r\n            using (TextWriter writer = new StreamWriter(SettingsFileName))\r\n            {\r\n                var csv = new CsvWriter(writer);\r\n                csv.WriteRecords(list); // where values implements IEnumerable\r\n            }\r\n\r\n            list.Clear();\r\n\r\n            using (TextReader fileReader = File.OpenText(SettingsFileName))\r\n            {\r\n                var csv = new CsvReader(fileReader);\r\n                csv.Configuration.HasHeaderRecord = true;\r\n                var records = csv.GetRecords<Person>();\r\n\r\n                try\r\n                {\r\n                    foreach (var record in records) //exception thrown here\r\n                    {\r\n                        list.Add(record); \r\n                    }\r\n                }\r\n                catch (Exception e)\r\n                {\r\n                    Console.WriteLine(e.Message);                   \r\n                }\r\n\r\n                Console.ReadKey();\r\n            }\r\n        }\r\n    }\r\n\r\n    class Person\r\n    {\r\n        public Person(string firstName, DateTime dateOfBirth)\r\n        {\r\n            FistName = firstName;\r\n            DateOfBirth = dateOfBirth;\r\n        }\r\n\r\n        public string FistName { get; set; }\r\n        public DateTime DateOfBirth { get; set; }\r\n\r\n\r\n    }\r\n}\r\n\r\n```\r\nThe exact exception message is:\r\n`Header matching ['firstName'] 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.`\r\n\r\nIf I change the property names to \"firstName\" and \"dateOfBirth\", it works. Am I doing someting wrong, or is there a work-around short of renaming the properties? I want to use this on existing classes and refactoring them to change the property names is not an option."},"comment":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/comments/406050522","html_url":"https://github.com/JoshClose/CsvHelper/issues/1078#issuecomment-406050522","issue_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/1078","id":406050522,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjA1MDUyMg==","user":{"login":"FireEater64","id":1670176,"node_id":"MDQ6VXNlcjE2NzAxNzY=","avatar_url":"https://avatars1.githubusercontent.com/u/1670176?v=4","gravatar_id":"","url":"https://api.github.com/users/FireEater64","html_url":"https://github.com/FireEater64","followers_url":"https://api.github.com/users/FireEater64/followers","following_url":"https://api.github.com/users/FireEater64/following{/other_user}","gists_url":"https://api.github.com/users/FireEater64/gists{/gist_id}","starred_url":"https://api.github.com/users/FireEater64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FireEater64/subscriptions","organizations_url":"https://api.github.com/users/FireEater64/orgs","repos_url":"https://api.github.com/users/FireEater64/repos","events_url":"https://api.github.com/users/FireEater64/events{/privacy}","received_events_url":"https://api.github.com/users/FireEater64/received_events","type":"User","site_admin":false},"created_at":"2018-07-18T19:41:51Z","updated_at":"2018-07-18T19:41:51Z","author_association":"NONE","body":"`Person` is not default constructable, and the only constructor for `Person` takes two named arguments - `firstName` and `dateOfBirth`. As a result - CsvHelper is attempting to use [onstructor mapping](https://joshclose.github.io/CsvHelper/configuration#constructor-mapping). If you capitalise the constructor parameters correctly, this should work:\r\n\r\n```csharp\r\nclass Person\r\n{\r\n    public Person(string FirstName, DateTime DateOfBirth)\r\n...\r\n```\r\n\r\nSimilarly, if you add a default constructor to `Person`, CsvHelper can use that - and then set the properties correctly.\r\n\r\n```csharp\r\nclass Person\r\n{\r\n    public Person() { }\r\n    public Person(string firstName, DateTime dateOfBirth) {\r\n...\r\n```\r\n\r\nIf you're unable the change the POCO in any way - you should be able to use `PrepareHeadersForMatch` to transform the headers into the correct format for your constructor. Example [here](https://joshclose.github.io/CsvHelper/examples).\r\n\r\n```csharp\r\nusing (TextReader fileReader = File.OpenText(SettingsFileName))\r\n{\r\n    var csv = new CsvReader(fileReader);\r\n    csv.Configuration.PrepareHeaderForMatch = header =>\r\n        CultureInfo.CurrentCulture.TextInfo.ToTitleCase(header);\r\n    var records = csv.GetRecords<Person>();\r\n...\r\n```\r\n\r\nHope this helps 😄 "}}
{"actor":{"display_login":"FireEater64"}}