当前位置: 首页>>代码示例>>C#>>正文


C# CSVFormat.Format方法代码示例

本文整理汇总了C#中Encog.Util.CSV.CSVFormat.Format方法的典型用法代码示例。如果您正苦于以下问题:C# CSVFormat.Format方法的具体用法?C# CSVFormat.Format怎么用?C# CSVFormat.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encog.Util.CSV.CSVFormat的用法示例。


在下文中一共展示了CSVFormat.Format方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadedRow

 /// <summary>
 ///     Construct a loaded row from an array.
 /// </summary>
 /// <param name="format">The format to store the numbers in.</param>
 /// <param name="data">The data to use.</param>
 /// <param name="extra">The extra positions to allocate.</param>
 public LoadedRow(CSVFormat format, double[] data, int extra)
 {
     int count = data.Length;
     _data = new String[count + extra];
     for (int i = 0; i < count; i++)
     {
         _data[i] = format.Format(data[i], 5);
     }
 }
开发者ID:jongh0,项目名称:MTree,代码行数:15,代码来源:LoadedRow.cs

示例2: ToList

 /// <summary>
 /// Convert an array of doubles to a comma separated list.
 /// </summary>
 /// <param name="format">The way to format this list.</param>
 /// <param name="precision">The precision.</param>
 /// <param name="result">This string will have the values appended to it.</param>
 /// <param name="data">The array of doubles to use.</param>
 public static void ToList(CSVFormat format, int precision, StringBuilder result,
                           double[] data)
 {
     result.Length = 0;
     for (int i = 0; i < data.Length; i++)
     {
         if (i != 0)
         {
             result.Append(format.Separator);
         }
         result.Append(format.Format(data[i], precision));
     }
 }
开发者ID:encog,项目名称:encog-silverlight-core,代码行数:20,代码来源:NumberList.cs

示例3: SaveCSV

        /// <summary>
        /// Save the dataset to a CSV file.
        /// </summary>
        /// <param name="targetFile">The target file.</param>
        /// <param name="format">The format to use.</param>
        /// <param name="set">The data set.</param>
        public static void SaveCSV(FileInfo targetFile, CSVFormat format, IMLDataSet set)
        {
            try
            {
                var file = new StreamWriter(targetFile.ToString());

                foreach (IMLDataPair data in set)
                {
                    var line = new StringBuilder();

                    for (int i = 0; i < data.Input.Count; i++)
                    {
                        double d = data.Input[i];
                        BasicFile.AppendSeparator(line, format);
                        line.Append(format.Format(d, EncogFramework.DefaultPrecision));
                    }

                    for (int i = 0; i < data.Ideal.Count; i++)
                    {
                        double d = data.Ideal[i];
                        BasicFile.AppendSeparator(line, format);
                        line.Append(format.Format(d, EncogFramework.DefaultPrecision));
                    }

                    file.WriteLine(line);
                }

                file.Close();
            }
            catch (IOException ex)
            {
                throw new EncogError(ex);
            }
        }
开发者ID:tonyc2a,项目名称:encog-dotnet-core,代码行数:40,代码来源:EncogUtility.cs

示例4: LoadAllData

        /// <summary>
        /// Load financial data.
        /// </summary>
        /// <param name="ticker">The ticker symbol.</param>
        /// <param name="output">The output file.</param>
        /// <param name="outputFormat">The output format.</param>
        /// <param name="from">Starting date.</param>
        /// <param name="to">Ending date.</param>
        public void LoadAllData(String ticker, String output, CSVFormat outputFormat, DateTime from,
            DateTime to)
        {
            try
            {
                Uri urlData = BuildURL(ticker, from, to);
                WebRequest httpData = WebRequest.Create(urlData);
                var responseData = (HttpWebResponse) httpData.GetResponse();

                if (responseData != null)
                {
                    Stream istreamData = responseData.GetResponseStream();
                    var csvData = new ReadCSV(istreamData, true, CSVFormat.English);

                    TextWriter tw = new StreamWriter(output);
                    tw.WriteLine("date,time,open price,high price,low price,close price,volume,adjusted price");

                    while (csvData.Next())
                    {
                        DateTime date = csvData.GetDate("date");
                        double adjustedClose = csvData.GetDouble("adj close");
                        double open = csvData.GetDouble("open");
                        double close = csvData.GetDouble("close");
                        double high = csvData.GetDouble("high");
                        double low = csvData.GetDouble("low");
                        var volume = (long) csvData.GetDouble("volume");

                        var line = new StringBuilder();
                        line.Append(NumericDateUtil.DateTime2Long(date));
                        line.Append(outputFormat.Separator);
                        line.Append(NumericDateUtil.Time2Int(date));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(open, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(high, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(low, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(close, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(volume);
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(adjustedClose, Precision));
                        tw.WriteLine(line.ToString());
                    }

                    tw.Close();
                }
            }
            catch (WebException ex)
            {
                throw new QuantError(ex);
            }
        }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:62,代码来源:YahooDownload.cs

示例5: ToList

 /// <summary>
 /// Convert an IMLData to a comma separated list.
 /// </summary>
 /// <param name="format">The way to format this list.</param>
 /// <param name="result">This string will have the values appended to it.</param>
 /// <param name="data">The array of doubles to use.</param>
 public static void ToList(CSVFormat format, StringBuilder result,
                           IMLData data)
 {
     result.Length = 0;
     for (int i = 0; i < data.Count; i++)
     {
         if (i != 0)
         {
             result.Append(format.Separator);
         }
         result.Append(format.Format(data[i], EncogFramework.DefaultPrecision));
     }
 }
开发者ID:jongh0,项目名称:MTree,代码行数:19,代码来源:NumberList.cs

示例6: LoadedRow

 /// <summary>
 /// Construct a loaded row from an IMLData.
 /// </summary>
 /// <param name="format">The format to store the numbers in.</param>
 /// <param name="data">The data to use.</param>
 /// <param name="extra">The extra positions to allocate.</param>
 public LoadedRow(CSVFormat format, IMLData data, int extra)
 {
     int count = data.Count;
     _data = new String[count + extra];
     for(int i = 0; i < count; i++)
     {
         _data[i] = format.Format(data[i], 5);
     }
 }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:15,代码来源:LoadedRow.cs

示例7: ToList

 public static void ToList(CSVFormat format, int precision, StringBuilder result, double[] data)
 {
     int num;
     result.Length = 0;
     if ((((uint) precision) + ((uint) num)) <= uint.MaxValue)
     {
         goto Label_007B;
     }
     if (0 == 0)
     {
         goto Label_0064;
     }
     Label_0022:
     if ((((uint) num) & 0) != 0)
     {
         goto Label_0064;
     }
     Label_0036:
     result.Append(format.Format(data[num], precision));
     num++;
     Label_004B:
     if (num < data.Length)
     {
         goto Label_0064;
     }
     if (((uint) num) >= 0)
     {
         return;
     }
     goto Label_007B;
     Label_0055:
     result.Append(format.Separator);
     goto Label_0022;
     Label_0064:
     if (num != 0)
     {
         goto Label_0055;
     }
     goto Label_0036;
     Label_007B:
     num = 0;
     if (0 != 0)
     {
         goto Label_0055;
     }
     goto Label_004B;
 }
开发者ID:neismit,项目名称:emds,代码行数:47,代码来源:NumberList.cs

示例8: LoadAllData

 public void LoadAllData(string ticker, string output, CSVFormat outputFormat, DateTime from, DateTime to)
 {
     try
     {
         HttpWebResponse response;
         ReadCSV dcsv;
         TextWriter writer;
         DateTime time;
         double num;
         double num2;
         double num3;
         double num4;
         double num5;
         long num6;
         StringBuilder builder;
         Uri requestUri = x38c212309d8d5dd3(ticker, from, to);
         goto Label_029A;
     Label_0010:
         builder.Append(outputFormat.Format(num, this.Precision));
         writer.WriteLine(builder.ToString());
     Label_0034:
         if (dcsv.Next())
         {
             goto Label_01E2;
         }
         writer.Close();
         return;
     Label_0049:
         builder.Append(outputFormat.Separator);
         builder.Append(outputFormat.Format(num3, this.Precision));
         builder.Append(outputFormat.Separator);
         builder.Append(num6);
         builder.Append(outputFormat.Separator);
         if ((((uint) num4) + ((uint) num2)) >= 0)
         {
             goto Label_0010;
         }
         return;
     Label_00B3:
         builder.Append(outputFormat.Format(num2, this.Precision));
         builder.Append(outputFormat.Separator);
         builder.Append(outputFormat.Format(num4, this.Precision));
         if ((((uint) num6) | 4) == 0)
         {
             goto Label_0034;
         }
         builder.Append(outputFormat.Separator);
     Label_0116:
         builder.Append(outputFormat.Format(num5, this.Precision));
         goto Label_0192;
     Label_012E:
         builder.Append(NumericDateUtil.DateTime2Long(time));
         builder.Append(outputFormat.Separator);
         builder.Append(NumericDateUtil.x93295384d7a86d9d(time));
         if ((((uint) num6) | 3) == 0)
         {
             goto Label_020C;
         }
         if (-2147483648 == 0)
         {
             goto Label_01FE;
         }
         builder.Append(outputFormat.Separator);
         goto Label_00B3;
     Label_0192:
         if (0 == 0)
         {
             goto Label_0049;
         }
         return;
     Label_019D:
         builder = new StringBuilder();
         if (((uint) num4) >= 0)
         {
             goto Label_012E;
         }
         goto Label_027A;
     Label_01BE:
         num5 = dcsv.GetDouble("low");
         num6 = (long) dcsv.GetDouble("volume");
         goto Label_0243;
     Label_01E2:
         time = dcsv.GetDate("date");
         num = dcsv.GetDouble("adj close");
     Label_01FE:
         num2 = dcsv.GetDouble("open");
     Label_020C:
         num3 = dcsv.GetDouble("close");
         num4 = dcsv.GetDouble("high");
         if ((((uint) num3) - ((uint) num4)) <= uint.MaxValue)
         {
             goto Label_01BE;
         }
     Label_0243:
         if ((((uint) num6) & 0) == 0)
         {
             goto Label_019D;
         }
     Label_0257:
         writer.WriteLine("date,time,open price,high price,low price,close price,volume,adjusted price");
//.........这里部分代码省略.........
开发者ID:neismit,项目名称:emds,代码行数:101,代码来源:YahooDownload.cs

示例9: SaveCSV

 public static void SaveCSV(FileInfo targetFile, CSVFormat format, IMLDataSet set)
 {
     try
     {
         StreamWriter writer = new StreamWriter(targetFile.ToString());
         using (IEnumerator<IMLDataPair> enumerator = set.GetEnumerator())
         {
             IMLDataPair pair;
             StringBuilder builder;
             int num;
             double num2;
             int num3;
             double num4;
             goto Label_002E;
         Label_0016:
             if ((((uint) num2) + ((uint) num2)) >= 0)
             {
             }
         Label_002E:
             if (enumerator.MoveNext())
             {
                 goto Label_00F5;
             }
             goto Label_012F;
         Label_003F:
             writer.WriteLine(builder);
             goto Label_0117;
         Label_004B:
             BasicFile.AppendSeparator(builder, format);
             builder.Append(format.Format(num4, 10));
             num3++;
         Label_0069:
             if (num3 >= pair.Ideal.Count)
             {
                 if (3 != 0)
                 {
                     goto Label_003F;
                 }
             }
             else
             {
                 num4 = pair.Ideal[num3];
                 goto Label_004B;
             }
         Label_0094:
             BasicFile.AppendSeparator(builder, format);
             builder.Append(format.Format(num2, 10));
             num++;
         Label_00B0:
             if (num < pair.Input.Count)
             {
                 goto Label_0107;
             }
             num3 = 0;
             goto Label_0069;
         Label_00CF:
             if (15 == 0)
             {
                 goto Label_0069;
             }
             if ((((uint) num3) | 0xff) != 0)
             {
                 goto Label_0094;
             }
         Label_00F5:
             pair = enumerator.Current;
             builder = new StringBuilder();
             num = 0;
             goto Label_00B0;
         Label_0107:
             num2 = pair.Input[num];
             goto Label_00CF;
         Label_0117:
             if (-2147483648 != 0)
             {
                 goto Label_0016;
             }
         }
     Label_012F:
         writer.Close();
     }
     catch (IOException exception)
     {
         throw new EncogError(exception);
     }
 }
开发者ID:neismit,项目名称:emds,代码行数:86,代码来源:EncogUtility.cs


注:本文中的Encog.Util.CSV.CSVFormat.Format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。