472,110 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

How to efficiently find a string in multiple text files?

The text files are not only the .txt files, but also all ascii files.

Thx.
Jan 3 '06 #1
5 3321
Buddhist,

For me a txt file is the same as an ascii file. (a classic name for a text
file)

Therefore can you make it more clear for us what you mean by this.

Be aware that finding strings in compressed or hassled files is not as easy
to do as in a txt file.

Cor
Jan 3 '06 #2
O, what I described was a little confusing and didn't make sense.

Actually, I want to ask how to searh a string in lots of text files quickly.
I implemented this by using System.IO(directory and file), read each line
and checked whether there was string desired, then recorded line numbers.
But its performance is very low, especially while processing lots of files.
So I am doubting whether directly using System.IO can meet my performance
requirement. Do I need to do many optimization by myself? And how?

Thx.
"Cor Ligthert [MVP]" <no************@planet.nl> дÈëÏûÏ¢
news:%2***************@TK2MSFTNGP15.phx.gbl...
Buddhist,

For me a txt file is the same as an ascii file. (a classic name for a text
file)

Therefore can you make it more clear for us what you mean by this.

Be aware that finding strings in compressed or hassled files is not as
easy to do as in a txt file.

Cor

Jan 3 '06 #3
Buddhist,
O, what I described was a little confusing and didn't make sense.

Actually, I want to ask how to searh a string in lots of text files
quickly.
I implemented this by using System.IO(directory and file), read each line
and checked whether there was string desired, then recorded line numbers.
But its performance is very low, especially while processing lots of
files.
So I am doubting whether directly using System.IO can meet my performance
requirement. Do I need to do many optimization by myself? And how?

That is in fact the only method I know as well, you can probably slightly
improve it by doing some multithreading with ony two threads, not more
(where the advantage is so low that I would not do it). (Finding the string
in an array can than be done seperated from retrieving the array).
Mutltithreading to read more files is without any sense and slows only your
application.

Have as well a look to this message from Jon some days ago.

http://groups.google.com/group/micro...149199c66b64bI hope this helps,Cor

Jan 3 '06 #4
Thx your help.

But I am dubious about the example by Jon.
Is checking each char in a huge char array very fast?
I'm afraid not.

Or there is sth I haven't understood.

"Cor Ligthert [MVP]" <no************@planet.nl> дÈëÏûÏ¢
news:u6**************@TK2MSFTNGP12.phx.gbl...
Buddhist,
O, what I described was a little confusing and didn't make sense.

Actually, I want to ask how to searh a string in lots of text files
quickly.
I implemented this by using System.IO(directory and file), read each line
and checked whether there was string desired, then recorded line numbers.
But its performance is very low, especially while processing lots of
files.
So I am doubting whether directly using System.IO can meet my performance
requirement. Do I need to do many optimization by myself? And how?

That is in fact the only method I know as well, you can probably slightly
improve it by doing some multithreading with ony two threads, not more
(where the advantage is so low that I would not do it). (Finding the
string in an array can than be done seperated from retrieving the array).
Mutltithreading to read more files is without any sense and slows only
your application.

Have as well a look to this message from Jon some days ago.

http://groups.google.com/group/micro...149199c66b64bI
hope this helps,Cor

Jan 4 '06 #5
Buddhist,

Sorry for Strings is the Visual Basic Find the fastest.

http://groups.google.com/group/micro...5c33cc87237dbf

See this test we did already a long while ago.

What we have tested is the Visual Basic find for finding strings twice as
fast as any other method.

Cor
Jan 4 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by hokiegal99 | last post: by
14 posts views Thread by Klaus Neuner | last post: by
9 posts views Thread by Jasper | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.