reading data from .csv file for stock program

nebeno

New member
Joined
Apr 10, 2008
Messages
2
Programming Experience
Beginner
Hi everyone,
I am having a tough time trying to figure out how to read and organize data from a comma separated .csv file containing stock market information (date, open, high, low, close, volume). I used to play around with programming stock trading systems with a proprietary system, where the data was already being read, and I just had to scan through for whatever I wanted (comparing opens and closes, other stocks, etc). So it's just the first step of drawing out the data and saving it (I guess into arrays?) that i'm not sure about. I guess I'm just not sure where to start. I can open the file, scan it (one character at a time) and print it in a textbox with each piece of data on a new line. But I'm not really sure if that's going to help me much (it's still saved as a string, and it's seems pretty slow).

I hope this makes sense, I guess I don't know the lingo enough to say what exactly the problem is.
Thanks
 
What you should do is read the entire contents of the file into a string then split the string using the Environment.NewLine character into a string array. Now all you need to do is loop through the string array (which is the individual lines in the file) then you can split that string on the comma which will give you the individual fields.

Personally I would make a class that has the properties that the csv file has for fields and you can have a collection of this class to hold all of the actual data.

I hope this doesn't sound too complicated for you, it's actually pretty easy stuff once you're used to it. I could make a quick demo that shows what I'm talking about.
 
Thanks for the replies guys. I've been trying out the things you suggested. Haven't quite got it to work though. JuggaloBrotha, if you could make me a little demo showing how this works that would be awesome. Thanks again.
 
Back
Top