-1

ここに画像の説明を入力
プロジェクトに FILEHELPER 2.0 を実装しようとしていますが、"" で囲まれたいくつかの csv ファイルが問題に直面しています。エラーが表示されています(これを示すエラーログ)

**" LineNumber | LineString |ErrorDescription 2|"Symbol","Date","Expiry","Strike Price","Open","High","Low","Close","LTP","Settle Price "、"いいえ。of contract","Turnover in Lacs","Open Int","Change in OI","Underlying Value "|長さを 0 未満にすることはできません。 -> パラメータ名:長さを 0 未満にすることはできません。 -> パラメータ名:長さ 3|" **

そして私のコードは次のようになります:

   var engine = new FileHelperEngine<script>();
   engine.Options.IgnoreFirstLines = 1; // skipping the header line

   script[] res = engine.ReadFile("agile.csv");  <<<<< at this line error occred 

そして私のクラスファイル:

     [DelimitedRecord(",")]
      public class script
    {
         [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
        public string Symbol;
         [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
        public string Date;
         [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
        public string Expiry;
         [FieldQuoted('"', QuoteMode.AlwaysQuoted)]

       ...
    }

そしてcsvファイルは.

"銘柄","日付","有効期限","行使価格","始値","高値","安値","終値","LTP","決済価格","契約数"," Lacs の売上高"、"Open Int"、"OI の変化"、"基礎となる価値"

"NIFTY","2012 年 8 月 31 日","2012 年 9 月 27 日"," 5400.00"," 56.00"," 56.90"," 38.05"," 44.45"," 43.55"," 44.45"," 281087 "," 765592.77"," 4845150"," 1334150"," 5258.50"

4

1 に答える 1

1

エラーの理由がわかりません: 次のコードは正常に動作します:

[DelimitedRecord(",")]
public class Script
{
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Symbol;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Date;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Expiry;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string StrikePrice;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Open;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string High;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Low;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string Close;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string LTP;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string SettlePrice;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string NoOfContracts;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string TurnOverInLacs;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string OpenInt;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string ChangeInOI;
    [FieldQuoted('"', QuoteMode.AlwaysQuoted)]
    public string UnderlyingValue;
}

class Program
{
    static void Main(string[] args)
    {
        string input = @"""Symbol"",""Date"",""Expiry"",""Strike Price"",""Open"",""High"",""Low"",""Close"",""LTP"",""Settle Price"",""No. of contracts"",""Turnover in Lacs"",""Open Int"",""Change in OI"",""Underlying Value """ + Environment.NewLine +
            @"""NIFTY"",""31-Aug-2012"",""27-Sep-2012"","" 5400.00"","" 56.00"","" 56.90"","" 38.05"","" 44.45"","" 43.55"","" 44.45"","" 281087"","" 765592.77"","" 4845150"","" 1334150"","" 5258.50""";

        var engine = new FileHelperEngine<Script>();
        engine.Options.IgnoreFirstLines = 1; // skipping the header line

        Script[] validRecords = engine.ReadString(input);

        // Check the third record
        Assert.AreEqual("NIFTY", validRecords[0].Symbol);
        Assert.AreEqual("31-Aug-2012", validRecords[0].Date);
        Assert.AreEqual("27-Sep-2012", validRecords[1].Date);
        // etc...            

        Console.WriteLine("All assertions passed");
        Console.Read();
    }
}
于 2012-09-03T08:38:08.053 に答える