CsvHelper 28.0.0 将 ShouldSkipRecordArgs
从属性 string[] Record
更改为 IReaderRow Row
。尽管此接口(interface)公开了 this
属性,但它没有实现 IEnumerable。
以前,您可以使用 ShouldSkipRecord = x => x.Record.All(field => string.IsNullOrWhiteSpace(field)) 将
。现在这已经不可能了。CsvReader
配置为跳过空白行
自 28.0.0 起,跳过空白行的推荐方法是什么?
问候, 罗布。
最佳答案
刚刚找到了进行此更改的提交,幸运的是单元测试显示了更新。 string[] Record
属性仍然存在,您只需导航到它即可。
更改:
ShouldSkipRecord = x => x.Record.All(field => string.IsNullOrWhiteSpace(field))
致:
ShouldSkipRecord = x => x.Row.Parser.Record?.All(field => string.IsNullOrWhiteSpace(field)) ??错误
关于c# - 如何跳过 CsvHelper >28.0.0 中的空白行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72937181/