【发布时间】:2016-05-05 02:13:37
【问题描述】:
我在解析 .csv 时使用 FileHelpers 创建分隔符字段时遇到问题。我的这一行数据在 LINQ 操作期间总是崩溃,类似于他们网站上的 filehelper 示例。
错误出现在列有引号的地方,例如这一行:
data1, data2, "data3a, data3b", data4
如何删除引号中的逗号,然后删除 data3a 和 data3b 的引号?
.csv 文件中的特定列有两个内容,但我不知道应该为此使用什么分隔符字段。
如果我不清楚,或者这个问题得到了回答,或者下面的评论没有目的。
非常感谢。
编辑: 类的代码
行:2010,NON-HISPANIC BLACK,MALE,"NEPHRITIS, NEPHROTIC SYNDROME AND NEPHROSIS",70,1
//delimiters, ignore first row, separate with comma
[DelimitedRecord(",")]
[IgnoreFirst()]
public class CauseofDeathClass
{
public int Year { get; set; }
public string Ethnicity { get; set; }
public string Sex { get; set; }
public string Cause_of_Death { get; set; }
public int Count { get; set; }
public int Percent { get; set; }
}
【问题讨论】:
-
你能展示你的代码以及哪里出错了吗?
-
我添加了类代码,通过.csv文件的代码类似于filehelpers.com上的分隔符示例
标签: c# csv entity delimiter filehelpers