次のようなCSVがあります。
a,b,c
a,b,c
a,"b,c",d
属性で区切られたクラスの2番目のフィールドをマークしています:
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForRead)]
public String ExchangeRate;
しかし、3行目はまだ「b、c」が2つの別々の値として解析されています。
私が何を間違っているのか分かりますか?
ありがとうございました
次のようなCSVがあります。
a,b,c
a,b,c
a,"b,c",d
属性で区切られたクラスの2番目のフィールドをマークしています:
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForRead)]
public String ExchangeRate;
しかし、3行目はまだ「b、c」が2つの別々の値として解析されています。
私が何を間違っているのか分かりますか?
ありがとうございました
あなたのコードに何も問題はありません。私はちょうどチェックしました:次のプログラムはうまくいきます:
[DelimitedRecord(",")]
public class MyClass
{
public string Field1;
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForRead)]
public string ExchangeRate;
public string Field3;
}
class Program
{
static void Main(string[] args)
{
var engine = new FileHelperEngine<MyClass>();
string fileAsString = @"a,b,c" + Environment.NewLine +
@"a,b,c" + Environment.NewLine +
@"a,""b,c"",d";
MyClass[] validRecords = engine.ReadString(fileAsString);
// Check the ExchangeRate values for rows 0, 1, 2 are as expected
Assert.AreEqual("b", validRecords[0].ExchangeRate);
Assert.AreEqual("b", validRecords[1].ExchangeRate);
Assert.AreEqual("b,c", validRecords[2].ExchangeRate);
Console.ReadKey();
}
}