C# CSV Parsing TypeConverter Example

Sometimes, you want to apply pre-defined conversions to csv field values, such as:

  • Parsing the string in a certain way, like removing first/last character, or replacing whitespaces with underscores.
  • Have a non-nullable type in a CSV model definition, while csv can actually contain empty values, so you want to provide a default value for them.

With CsvHelper, this functionality is typically achieved using a custom TypeConverter.