首页 > 解决方案 > 在 CsvHelper v7.1.1 中读取“未键入”的 CSV 文件

问题描述

在 CsvHelper 2.16.3 中,我有以下代码

    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;
    }

我正在升级一些软件包,我发现它CsvReader.CurrentRecord在某些时候已被弃用和删除。从 7.1.1 版开始重写它的最佳方法是什么?

标签: csvhelper

解决方案


很多东西都移到了上下文对象中。csv.Context.Record


推荐阅读