使用C#,我需要解析一个不是来自文件的CSV字符串。我找到了很多关于解析CSV文件的资料,但几乎没有任何关于字符串的资料。看起来这应该很简单,但到目前为止我只能想出一些效率低下的方法,比如:
using Microsoft.VisualBasic.FileIO;
var csvParser = new TextFieldParser(new StringReader(strCsvLine));
csvParser.SetDelimiters(new string[] { "," });
csvParser.HasFieldsEnclosedInQuotes = true;
有没有什么好的方法可以让它更高效,更美观?我将处理大量的字符串,所以我不想支付以上所有的费用。谢谢。
1条答案
按热度按时间bbmckpt71#
下面是一个经过简单测试的处理引号的解析器