使用 FileHelpers 的条件记录类型
我正在尝试使用 Filehelpers 库解析文件。我的文件如下所示:
000001,"A",123,456
000002,"B","ABC","XYZ"
000003,"B","DEF","XYZ"
000004,"B","HIJ","XYZ"
我的文件包含具有不同列定义的行,其中行的“类型”由第二列中的字符定义。即在上面的示例中,我有一个“A”行,后面跟着三个“B”行。
Filehelpers 要求我在实例化文件助手引擎时传递用于定义行的 CLR 类型,或者使用如下通用版本。
FileHelperEngine<ARecord> engine = new FileHelperEngine<ARecord>()
这意味着我只能使用单一类型来定义文件中的每一行。 有什么方法可以解析这样的文件并根据给定行的一部分有条件地指定记录类型?
I'm trying to parse a file using the Filehelpers library. My file looks like this:
000001,"A",123,456
000002,"B","ABC","XYZ"
000003,"B","DEF","XYZ"
000004,"B","HIJ","XYZ"
My file contains rows that have different column definitions, where the 'type' of row is defined by the character in the second column. i.e. In the sample above I have an "A" row followed by three "B" rows.
Filehelpers requires that I pass the CLR type used to define a row when I instantiate the file helpers engine, or us the generic version as below.
FileHelperEngine<ARecord> engine = new FileHelperEngine<ARecord>()
This means I'm restricted to a single type to define every row in my file.
Is there any way I can parse a file like this and conditionally specify the record type based on a part of the given row?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了。 http://www.filehelpers.com/example_multirecords.html
found it. http://www.filehelpers.com/example_multirecords.html