|
-
Apr 22nd, 2009, 06:59 AM
#1
Thread Starter
Lively Member
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
-
Apr 22nd, 2009, 07:13 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 22nd, 2009, 07:13 AM
#3
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|