Click here to Skip to main content
11,576,293 members (58,660 online)
Click here to Skip to main content
Add your own
alternative version

Financial Predictor via Neural Network

, 25 May 2011 CPOL 113.3K 15.9K 180
Exploring the prediction capability of neural networks
Release2.zip
Cloo.dll
dow.csv
encog-core-cs.dll
FinancialMarketPredictor.exe
log4net.dll
nasdaq.csv
predictor_0.08.ntwrk
rates.csv
SP500.csv
Sources2.zip
FinancialMarketPredictorArticle
FinancialMarketPredictor
bin
Debug
Cloo.dll
dow.csv
encog-core-cs.dll
log4net.dll
nasdaq.csv
rates.csv
SP500.csv
Release
Entities
Properties
Settings.settings
Utilities
// ciumac.sergiu@gmail.com

using System.IO;
using System.Text;

namespace FinancialMarketPredictor.Utilities
{
    /// <summary>
    /// Class for writing any object values in comma separated file
    /// </summary>
    public class CSVWriter
    {
        /// <summary>
        /// Char separator
        /// </summary>
        private const char SEPARATOR = ',';

        /// <summary>
        /// Path to file to be written
        /// </summary>
        private readonly string _pathToFile;

        /// <summary>
        /// Stream writer
        /// </summary>
        private StreamWriter _writer;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pathToFile">Path to filename</param>
        public CSVWriter(string pathToFile)
        {
            _pathToFile = pathToFile;
        }

        /// <summary>
        /// Write the data into csv
        /// </summary>
        /// <param name="data">Data to be written</param>
        [System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.Demand)]
        public void Write(object[,] data)
        {
            using (_writer = new StreamWriter(_pathToFile))
            {
                int cols = data.GetLength(1);
                for (int i = 0, n = data.GetLength(0); i < n; i++)
                {
                    StringBuilder builder = new StringBuilder();
                    for (int j = 0; j < cols; j++)
                    {
                        builder.Append(data[i, j]);
                        if (j != cols - 1)
                            builder.Append(SEPARATOR);
                    }
                    _writer.WriteLine(builder.ToString());
                }
                _writer.Close();
            }
        }
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ciumac Sergiu
Software Developer
Moldova (Republic Of) Moldova (Republic Of)
Interested in computer science, math, research, and everything that relates to innovation. Fan of agnostic programming, don't mind developing under any platform/framework if it explores interesting topics. In search of a better programming paradigm.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150603.1 | Last Updated 25 May 2011
Article Copyright 2011 by Ciumac Sergiu
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid