Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Simple (to you, not me) String Issue In C#

Name: Anonymous 2011-03-09 20:52

I'm trying to read financial asset prices into an array, and I have a file that's set up like so:

"Date","Open","High","Low","Close","Volume","OpenInt"
03/19/1999,97.97,97.97,97.97,97.97,0,0
03/22/1999,97.83,97.83,97.83,97.83,0,0
03/23/1999,97.79,97.79,97.79,97.79,0,0

I'm just trying to learn how to load this data into an array right now, but I am having trouble with getting the program to separate the last entry on a line from the first entry on the next line.

In the code below, I am trying to get the program to skip the headers (i.e., "Date", "Open", etc.). But, no matter what I do (i.e., require i>7 or i>6), I either lose the date on the second line along with the "Open Int" heading, or I lose both of them. I need to just get rid of the "Open Int".

Here's the code. I didn't get to using the for loop yet. The carriage return replace bit was in an effort to change the string so that it could separate the two... Replacing \r and \n produced no results...

I'm using Visual C# Express as I have not yet made my fortune in the financial markets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            // create a reader and open the file
            StreamReader tr = new StreamReader("c:\\users\\b\\downloads\\dx\\DX00H.txt");
            StreamWriter wr = new StreamWriter("c:\\users\\b\\downloads\\dx\\output.txt");

            // read the entire file
            string myString=(tr.ReadToEnd());
       
           
            myString = myString.Replace("\"", " ");
            myString = myString.Replace("\\r", ",\\r ");
            string[] sArray =(myString.Split(','));

            string[][] aLines;


            int i = 0;
            foreach (string s in sArray)
            {
                i++;
                Console.WriteLine(s);
                if (i > 6)
                    wr.Write(s + " ");
           
            }



            // close the stream
            tr.Close();
            Console.ReadLine();

        }
    }
}

Name: Anonymous 2011-03-10 1:40

>>10
mailto:noko
Tsk.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List