?
Solved

search for string within text file

Posted on 2003-03-06
8
Medium Priority
?
121 Views
Last Modified: 2010-04-04
How Can I Read Specific String whithin very Very Large
Text File with High performance,

please Advice me as soon as posible.

thanks
0
Comment
Question by:moutaz_ima
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8079995
Hi.

Do a search on the net for Boyer-Moore Horspool. AFAIK that's one of the best search algorithms for large texts.

Markus
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8080107
0
 
LVL 7

Expert Comment

by:billious
ID: 8080204
I gather the problem is more that the text won't fit into a Tmemo, or whatever.

I believe you should examine conventional file-handling, with specific reference to BLOCKREAD, and then do a byte-by-byte scan on the data read.

Whereas smartening up the program is nice academically, it might be of little practical value with the speed of today's machines when compared with the I/O time for the file to be physically read from the mass media.

A simple speed-up could be to find the character in your search-for string that has the LOWEST usage rate in the text file in question. For instance, if your text file is in English, and you have a Q as the third character in your search-string, search for the Q, then try to match your string starting at buffer[q_location_found - position_of_q_in_search_string]

If you have no q's, then try J,Z,X, etc. There should be a letter-frequency list somewhere on the net!

HTH

...Bill
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:ILE
ID: 8080229
text files have a sequentional acces

if the text file is samler then 32kb of text u mey use
memo component
memo1.loadfromfile('filepath+filename');
and after that u use standard memo command

u mey also use
tstrings  and again loadfromfile metod


but the fastest metod is the foloving
if u search for some string in the textfile;

proceure searchtext(s:string):string;
var f:textfiel;
    sq:string;
begin
assign(f,'filepath+filename);
reset(f);
while not eof(f) do
begin
 readln(f,sq);
 if pos(s,sq)>0 then begin break; end;   {here u mey do enything u wont i u search for strign from textfile }
end;
closefile(f);
end;

procedure getcolmun(i:longint);
i1:longint;
begin
assign(f,'filepath+filename);
reset(f);
i1:=0;
while not eof(f) do
begin
 readln(f,sq);
 inc(i1);
  if i=i1 then  begin  {in the sq is the i-th line of text from textfile}      break;    end;
end;
closefile(f);

end;




0
 
LVL 3

Expert Comment

by:ILE
ID: 8080262
text files have a sequentional acces

if the text file is samler then 32kb of text u mey use
memo component
memo1.loadfromfile('filepath+filename');
and after that u use standard memo command

u mey also use
tstrings  and again loadfromfile metod


but the fastest metod is the foloving
if u search for some string in the textfile;

proceure searchtext(s:string):string;
var f:textfiel;
    sq:string;
begin
assign(f,'filepath+filename);
reset(f);
while not eof(f) do
begin
 readln(f,sq);
 if pos(s,sq)>0 then begin break; end;   {here u mey do enything u wont i u search for strign from textfile }
end;
closefile(f);
end;

procedure getcolmun(i:longint);
i1:longint;
begin
assign(f,'filepath+filename);
reset(f);
i1:=0;
while not eof(f) do
begin
 readln(f,sq);
 inc(i1);
  if i=i1 then  begin  {in the sq is the i-th line of text from textfile}      break;    end;
end;
closefile(f);

end;




0
 

Expert Comment

by:CleanupPing
ID: 9316907
moutaz_ima:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10044956
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

PAQ'd and pts refunded

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10113865
PAQed, with points refunded (25)

modulo
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question