|
-
January 22nd, 2004, 11:08 AM
#1
How to locate a record
I have a very large text file containing records that consist of a NULL terminated Name (vartiable length) followed by an Int. I need a routine which will find a particular record for a given name.
What would be a good way to accomplish this?
TIA
--------------------------------------------
http://www.volfirst.net/~sirjorj/index.html
---------------------------------------------
-
January 22nd, 2004, 12:03 PM
#2
Create an ADO recordset, read in and parse the file and put the data into the recordset fields. You can then do a find call and find any specific row of data you need.
-
January 22nd, 2004, 02:55 PM
#3
Thank you Adam for your reply. However, I'm not concerned with a DataBase Management program and I'm not familiar with ADO and was hoping for a simpler approach. The records, I might add, are already sorted on Name. Another approach would be appreciated.
--------------------------------------------
http://www.volfirst.net/~sirjorj/index.html
---------------------------------------------
-
January 22nd, 2004, 03:01 PM
#4
I have a very large text file containing records that consist of a NULL terminated Name (vartiable length) followed by an Int. I need a routine which will find a particular record for a given name.
What would be a good way to accomplish this?
TIA
Perhaps you could just create a search routine which reads each line in the file then performs a check on the line. You can parse the line so that it separates the name and number as needed.
Last edited by bluesource; January 22nd, 2004 at 03:06 PM.
-
January 22nd, 2004, 03:50 PM
#5
Do you need to do this find repeatedly, or just once? How big is the text file?
-
January 22nd, 2004, 06:15 PM
#6
See the following for an efficient string search algorithm:
Boore - Moore Search
You'll probably have to make modifications since you indicated that you have 'ints' in your file -- it uses strlen functions and you'd probably get premature returns
-
January 23rd, 2004, 08:50 AM
#7
make HASH code for each record in you file (index file)
story codes in separate file (or in some)
and add to code offset value of record from start of file
to find record all you need is find it HASH code in table
and you get offset in file.
-
January 23rd, 2004, 09:26 AM
#8
In answer to GCDEF's question- This would be a one-time thing.
I need the number that is associated with each name then the source file is scrap. And, Oh yes, the size of the source file is 120k byts.
Last edited by Sirjorj; January 23rd, 2004 at 09:37 AM.
--------------------------------------------
http://www.volfirst.net/~sirjorj/index.html
---------------------------------------------
-
January 23rd, 2004, 10:30 AM
#9
Originally posted by Sirjorj
In answer to GCDEF's question- This would be a one-time thing.
I need the number that is associated with each name then the source file is scrap. And, Oh yes, the size of the source file is 120k byts.
Well, 120K isn't that big. If you only need to do it once, it doesn't need to be particularly effecient. I'd just read it into a large char array and look for the value you want.
-
January 23rd, 2004, 11:34 AM
#10
You can read the entire file in and since the records are sorted you can do a simple binary search using bsearch() to speed up your search.
-
January 23rd, 2004, 11:45 AM
#11
Originally posted by Tron
You can read the entire file in and since the records are sorted you can do a simple binary search using bsearch() to speed up your search.
Variable length strings.
-
January 23rd, 2004, 06:21 PM
#12
Thanks all,
You have given me some ideas to pursue.
--------------------------------------------
http://www.volfirst.net/~sirjorj/index.html
---------------------------------------------
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
|