CsvHelper Ignore case for header names

If you are using the http://joshclose.github.io/CsvHelper/ you can provide some configuration when constructing the CsvReader or configuring it after construction.

    using (var stringReader = new StringReader(yourString))
    using (var csvReader = new CsvReader(stringReader))
    {
        // Ignore header case.
        csvReader.Configuration.PrepareHeaderForMatch =  (string header, int index) => header.ToLower();
        return csvReader.GetRecords<Import>().ToList();
    }

There is more documentation in the PrepareHeaderForMatch section at https://joshclose.github.io/CsvHelper/api/CsvHelper.Configuration/Configuration/

For more granularity there are also class mapping instructions for which can be found under here:
https://joshclose.github.io/CsvHelper/examples/configuration

Hope that helps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)