Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Text File and Return Value

Status
Not open for further replies.

byrne1

Programmer
Aug 7, 2001
415
0
0
US
I have a 2.0MB text file that is composed of lines of data for customers. Each line contains the customer account number along with additional information for that customer. I need to rapidly search this file for a given account number and return information for the customer.

I can do this easily using LINE INPUT but, as expected, it is painfully slow. Is there a better way to search a file and still be able to return data from the file?

Thanks in advance for any help!
 
Hmmmmmmmmmmmmm,

I usually just input the entire file into a string variable and split it into "records" and "Fields" in array(s). then, do the searches on the arrays.

It is easier/better in the 'long run' to convert the mass of text into SOME type of db, then you can do standard SQL searches.

Actually, you can just reference the text file (assuming it IS delimited) as an ADO recordset and do SQL selects directly from that, but multiuser updating is a bit of a hassle.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
The best way to do it is to import your text file into a database and use the ADO objects to bang up against it. That's what a database is for.
 
The file is produced from our mainframe every month and is just a fixed length flat file, not delimited by anything. I thought of importing the data into a DB but that would take just as long if not longer that what I'm already doing.
 
Hmmmmmmmmmmmmm,

I usually just input the entire file into a string variable and split it into "records" and "Fields" in array(s). then, do the searches on the arrays.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
If you can get the data in a sorted format, you could then open the file as a random access file, since it’s a fixed length and search using a binary search. If you can't sort it, then it's a painful sequential search method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top