• <i id='nuF7L'><tr id='nuF7L'><dt id='nuF7L'><q id='nuF7L'><span id='nuF7L'><b id='nuF7L'><form id='nuF7L'><ins id='nuF7L'></ins><ul id='nuF7L'></ul><sub id='nuF7L'></sub></form><legend id='nuF7L'></legend><bdo id='nuF7L'><pre id='nuF7L'><center id='nuF7L'></center></pre></bdo></b><th id='nuF7L'></th></span></q></dt></tr></i><div id='nuF7L'><tfoot id='nuF7L'></tfoot><dl id='nuF7L'><fieldset id='nuF7L'></fieldset></dl></div>

      <legend id='nuF7L'><style id='nuF7L'><dir id='nuF7L'><q id='nuF7L'></q></dir></style></legend>

        <small id='nuF7L'></small><noframes id='nuF7L'>

        <tfoot id='nuF7L'></tfoot>
          <bdo id='nuF7L'></bdo><ul id='nuF7L'></ul>

        在 C# 中解析带有标题的 CSV 文件

        时间:2023-08-26
          <tbody id='96tYi'></tbody>

        <small id='96tYi'></small><noframes id='96tYi'>

        <i id='96tYi'><tr id='96tYi'><dt id='96tYi'><q id='96tYi'><span id='96tYi'><b id='96tYi'><form id='96tYi'><ins id='96tYi'></ins><ul id='96tYi'></ul><sub id='96tYi'></sub></form><legend id='96tYi'></legend><bdo id='96tYi'><pre id='96tYi'><center id='96tYi'></center></pre></bdo></b><th id='96tYi'></th></span></q></dt></tr></i><div id='96tYi'><tfoot id='96tYi'></tfoot><dl id='96tYi'><fieldset id='96tYi'></fieldset></dl></div>

          <bdo id='96tYi'></bdo><ul id='96tYi'></ul>

            1. <tfoot id='96tYi'></tfoot>

              • <legend id='96tYi'><style id='96tYi'><dir id='96tYi'><q id='96tYi'></q></dir></style></legend>
                  本文介绍了在 C# 中解析带有标题的 CSV 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否有默认/官方/推荐的方式来解析 C# 中的 CSV 文件?我不想滚动我自己的解析器.

                  Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser.

                  此外,我还看到人们使用 ODBC/OLE DB 通过文本驱动程序读取 CSV 的实例,但由于它的缺点",很多人不鼓励这样做.这些缺点是什么?

                  Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "drawbacks." What are these drawbacks?

                  理想情况下,我正在寻找一种可以按列名读取 CSV 的方法,将第一条记录用作标题/字段名称.给出的一些答案是正确的,但基本上可以将文件反序列化为类.

                  Ideally, I'm looking for a way through which I can read the CSV by column name, using the first record as the header / field names. Some of the answers given are correct but work to basically deserialize the file into classes.

                  推荐答案

                  让图书馆为您处理所有细节!:-)

                  Let a library handle all the nitty-gritty details for you! :-)

                  查看 FileHelpers 并保持干燥 - 不要重复自己 - 无需重新发明轮子无数次....

                  Check out FileHelpers and stay DRY - Don't Repeat Yourself - no need to re-invent the wheel a gazillionth time....

                  您基本上只需要通过公共类(以及经过深思熟虑的属性,如默认值、NULL 值的替换等)来定义数据的形状 - CSV 中单独行中的字段),将 FileHelpers 引擎指向一个文件,然后宾果游戏 - 您从该文件中取回所有条目.一个简单的操作 - 出色的性能!

                  You basically just need to define that shape of your data - the fields in your individual line in the CSV - by means of a public class (and so well-thought out attributes like default values, replacements for NULL values and so forth), point the FileHelpers engine at a file, and bingo - you get back all the entries from that file. One simple operation - great performance!

                  这篇关于在 C# 中解析带有标题的 CSV 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:System.Web.Extensions 程序集无法解析 下一篇:使用 System.Net.WebRequest 时无法设置某些 HTTP 标头

                  相关文章

                  最新文章

                • <small id='9IV4u'></small><noframes id='9IV4u'>

                    <bdo id='9IV4u'></bdo><ul id='9IV4u'></ul>
                  <i id='9IV4u'><tr id='9IV4u'><dt id='9IV4u'><q id='9IV4u'><span id='9IV4u'><b id='9IV4u'><form id='9IV4u'><ins id='9IV4u'></ins><ul id='9IV4u'></ul><sub id='9IV4u'></sub></form><legend id='9IV4u'></legend><bdo id='9IV4u'><pre id='9IV4u'><center id='9IV4u'></center></pre></bdo></b><th id='9IV4u'></th></span></q></dt></tr></i><div id='9IV4u'><tfoot id='9IV4u'></tfoot><dl id='9IV4u'><fieldset id='9IV4u'></fieldset></dl></div>

                  <legend id='9IV4u'><style id='9IV4u'><dir id='9IV4u'><q id='9IV4u'></q></dir></style></legend>

                    1. <tfoot id='9IV4u'></tfoot>