View Single Post
Old 08-08-2007, 10:53 AM   #143 (permalink)
Neags23
All Star Starter
 
Neags23's Avatar
 
Join Date: Apr 2006
Posts: 1,155
Quote:
Originally Posted by Comedian2004 View Post
The problem is, there is no way that I can tell how many items are in the file, without reading the file in twice. Not a solution.

An array is like this:

dim Players() as string

now, I can redimension that to add players. I redim it after each read and redim it to the players ID. But, I can do this with an array like this:

dim Players(NumPlayers, StatFields), as I have to know how many players there are and how many fields.

Anyhow, in this example, I load in the entire players_at_bat_batting_stats.csv file and then when I want to access it again, I just access the array.

This will speed up tons of my utils and open some doors that were closed (and had a barricade) before. We are talking about a routine that took 15 minutes before, will now take 15 seconds.
Larry, there may be a more memory efficient way to do this than re-instantiating the array each time.

There is a readToEnd() method in .net that will return the entire file as one huge string. Use a streamreader to do this. Assign the array to be whatever size the length of that string is (using string.length() -- then divide by 50 or so). Last, just split the string with the "\n" character using the split("\n") method, and that fills up your array.
__________________
Checkout my TeamRater mod!

Checkout my Player Development Tracker for Solo Leagues!

Neags23 is offline   Reply With Quote