By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

How to efficiently find a string in multiple text files?

P: n/a
The text files are not only the .txt files, but also all ascii files.

Thx.
Jan 3 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.