[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 123
  • Last Modified:

search for string within text file

How Can I Read Specific String whithin very Very Large
Text File with High performance,

please Advice me as soon as posible.

thanks
0
moutaz_ima
Asked:
moutaz_ima
1 Solution
 
DaFoxCommented:
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
 
billiousCommented:
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
ILECommented:
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
 
ILECommented:
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
 
CleanupPingCommented:
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
 
snehanshuCommented:
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
 
moduloCommented:
PAQed, with points refunded (25)

modulo
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now