Question about reading a text file.
I have a text file with single line entries, running in the hundreds, if not thousands. And the text file gets continually populated. Basically its a baseball score list with each players latest stats coming in the last line of the file. The format for the file is as follows.
Name, At bats, hits, singles, doubles, triples, homeruns, avg
BEN, 110, 34, 24, 9, 1, 6, 3.09
ART, 109, 24, 19, 2, 0, 3, 2.20
BEN, 111, 34, 24, 9, 1, 6, 3.09
MIKE, 100, 30, 27, 3, 0, 4, 3.00
What I want to do is extract the last value for each name only. I mean, if I want Ben's stats, I just want the latest entry in the file, since thats the most recent. How can i go about doing that? I have fidgeted around with code a lot, but got nowhere.
Basically I need a way to read the file from the bottom up, searching for the first record for each name, since that will be the latest entry for that name.
Any ideas, or pointers?
Thanks
Re: Question about reading a text file.
read the entire file into an array, loop through the array from the bottom,
if the file is getting too large consider a database file
Re: Question about reading a text file.
Using text file for what you need is not reasonable at all - since its size growing your apps performance will be degrading tremendously.
Why not creating a small database (MS Acces, MS SQL Express, etc) so you can filter what you want by date/name/etc?