.net - 跳过 FileHelper 中的列

标签 .net csv filehelpers

使用 FileHelper .Net 库,我可以以某种方式跳过源文件中的一些列吗?

根据文档和示例,我必须为所有列添加字段。唉,我有一个包含 216 列的 Excel 表要导入,其中只需 13 列。

最佳答案

我也有同样的情况,还有疑问。在 filehelpers.net 上搜索论坛,我找到了 thread (从 2007 年开始?!)马科斯本人回应:

问题:

In a delimited length layout, is it possible to skip some fields? For example:
ExternalSysId|ExportDate|FirstName|LastName
I only want FirstName and LastName, and don't want to clutter up my code with "dummy" fields?



回复:

The library dont have a built in feature for this.

You can make the fields private, the library will read the values, but you dont see them from your code =) If in the future you need these fields you can meke them public



因此,使用记录类向导来减少所需的输入量,然后将不必要的字段设为私有(private),这似乎是目前最好的选择。

关于.net - 跳过 FileHelper 中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/352030/

相关文章:

c# - 使用固定长度字段的可变长度数组解析消息

c# - Filehelpers CSV 解析。如何使用 FieldQuoted 属性?

csv - Cypher 用 python 加载 csv

c# - .NET 如何从匿名类型的枚举中输出 csv?

c# - 按路径加载 XML 文件

c# - 需要 : A Windows Service That Executes Jobs from a Job Queue in a DB; Wanted: Example Code

c# - .NET 中的动态 WSDL 位置

c# - 基于文化的十进制字符串格式

python - 追加到列表列表中的一个列表也追加到所有其他列表

python - 在 Django View 中执行 Python 脚本 [上传 CSV -> 批量地理编码 -> 通过脚本生成的 CSV 显示下载链接]