更改 FileHelpers EOL 字符
我正在尝试将 10GB 的 .dat 文件解析为 .NET 中可识别的内容。列分隔符是“~”,EOL 是“++EOL++”。我知道如何处理分隔符,但当文件中没有实际换行符时,我找不到处理“++EOL++”的简单方法。这可以通过 FileHelpers 中的选项来处理还是我必须编写一些自定义的东西?
I'm trying to parse 10GB of .dat files into something recognizable in .NET. The column delimiter is a '~' and the EOL is a '++EOL++'. I know how to handle the delimiter but I can't find an easy way to handle the '++EOL++' when there are no actual line breaks in the file. Can this be handled with an option in FileHelpers or would I have to write something custom?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,No FileHelpers 不支持具有异常行尾字符序列的文件。
预解析文件并替换 EOL 序列可能是最简单的方法。但是,它是一个可扩展的库,因此您可以创建自己的 DataStorage 子类。您本质上必须重写
并创建一个新类 MyStreamReader,它与(不幸的是
sealed
)InternalStreamReader
相同,但ReadLine
除外。包含 EOL 代码(顺便说一下,我指的是 FileHelpers 2.9.9 的源代码。版本 2.0.0 似乎使用
System.IO.StreamReader
所以你可以只需对其进行子类化,而不是复制InternalStreamReader
。No FileHelpers does not support files with unusual end-of-lines character sequences by default.
It would probably be easiest to pre-parse the file and replace the EOL sequences. However, it is an extensible library, so you could create your own DataStorage subclass. You would essentially have to override
and then create a new class MyStreamReader, which would be identical to the (unfortunately
sealed
)InternalStreamReader
except forReadLine
which contains the EOL code(By the way I'm referring to the source code for FileHelpers 2.9.9. Version 2.0.0 seems to use a
System.IO.StreamReader
so you can just subclass it instead of duplicatingInternalStreamReader
.