Search code examples
csvhelper

Reading "un-typed" CSV files in CsvHelper v7.1.1


In CsvHelper 2.16.3, I had the following code

    public static IEnumerable<IEnumerable<string>> GetAllRecords(TextReader reader)
    {
        List<IEnumerable<string>> records = new List<IEnumerable<string>>();
        var csvConfiguration = new CsvConfiguration { HasHeaderRecord = false };

        using (var csv = new CsvReader(reader, csvConfiguration))
        {
            while (csv.Read())
            {
                records.Add(csv.CurrentRecord);
            }
        }

        return records;
    }

I'm upgrading some packages and I found that CsvReader.CurrentRecord was deprecated and removed at some point. What's the best way to rewrite this as of version 7.1.1?


Solution

  • A lot of stuff moved to a context object. csv.Context.Record