有没有办法使用 LinqToCSV 并只选择特定的列?
例如,我需要每天摄取一个 CSV 文件,一个月可能有 14 列,下个月可能有 15 列。目前我已将其配置为映射所有 14 列,但这确实不理想,因为我真正关心的只有 10 列。
因此,当我抛出一个额外的列时,我会抛出一个 TooManyDataFieldsException 并且 LinqToCSV 不会读取 CSV 文件的任何行。
最佳答案
看这里:http://www.codeproject.com/Articles/25133/LINQ-to-CSV-library#EnforceCsvColumnAttribute
When true, Read only reads data fields into public fields and properties with the [CsvColumn] attribute, ignoring all other fields and properties. And, Write only writes the contents of public fields and properties with the [CsvColumn] attribute.
关于.net - 使用 LinqToCSV - 忽略额外的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12351436/