将 CSV 文件导入到 .Net 中的强类型数据结构 [英] Import CSV file to strongly typed data structure in .Net

查看:26
本文介绍了将 CSV 文件导入到 .Net 中的强类型数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 CSV 文件导入强类型数据结构的最佳方法是什么?

What's the best way to import a CSV file into a strongly-typed data structure?

推荐答案

Microsoft 的 TextFieldParser 稳定并遵循 RFC 4180CSV 文件.不要被 Microsoft.VisualBasic 命名空间所拖延;它是 .NET Framework 中的标准组件,只需添加对全局 Microsoft.VisualBasic 程序集的引用.

Microsoft's TextFieldParser is stable and follows RFC 4180 for CSV files. Don't be put off by the Microsoft.VisualBasic namespace; it's a standard component in the .NET Framework, just add a reference to the global Microsoft.VisualBasic assembly.

如果您正在为 Windows 编译(而不是 Mono)并且不期望必须解析损坏的"(非 RFC 兼容的)CSV 文件,那么这将是显而易见的选择,因为它是免费的、不受限制的、稳定的并且受到积极支持,其中大部分不能用于 FileHelpers.

If you're compiling for Windows (as opposed to Mono) and don't anticipate having to parse "broken" (non-RFC-compliant) CSV files, then this would be the obvious choice, as it's free, unrestricted, stable, and actively supported, most of which cannot be said for FileHelpers.

另见:如何:在 Visual 中读取逗号分隔的文本文件基本 VB 代码示例.

See also: How to: Read From Comma-Delimited Text Files in Visual Basic for a VB code example.

这篇关于将 CSV 文件导入到 .Net 中的强类型数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆