CsvHelper – Header with name not found

When your CSV header names don’t match your property names exactly, CsvHelper will throw an exception. For example, if your header name is “title” and your property name is “Title”, it’ll throw an exception like: HeaderValidationException: Header with name ‘Title'[0] was not found. If you don’t want to (or can’t) change the names to match, … Read more

C# – Using CsvHelper when there’s no header row

In this article, I’ll show how to configure CsvHelper to map CSV fields to the right properties when there’s no header row. At the end, I’ll show the alternative approach of manually parsing in this scenario. Consider the following CSV data without a header row: Normally, CsvHelper maps fields to properties by matching column names … Read more

C# – Parsing a CSV file

In this article, I’ll show how to parse a CSV file manually and with a parser library (CsvHelper). Let’s say you have the following CSV file: To manually parse this, split each line with a comma and process the fields in the resulting string[] however you want. If there’s a header row, skip it (headers … Read more