473,569 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3420
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(direc tory 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******** *******@TK2MSFT NGP15.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(direc tory 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******** ******@TK2MSFTN GP12.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(direc tory 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
33845
by: hokiegal99 | last post by:
How do I say: x = string.find(files, 'this', 'that', 'the-other') currently I have to write it like this to make it work: x = string.find(files, 'this') y = string.find(files, 'that') z = string.find(files, 'the-other')
14
1518
by: Klaus Neuner | last post by:
Hello, I need to gather information that is contained in various files. Like so: file1: ===================== foo : 1 2 bar : 2 4
1
3713
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
5
2096
by: Jim | last post by:
Hello, I am working on a small windows application for a client, and as one of the functions they want a search that will let them enter a search string, then search a directory for all flies that contain that search string AND display the lines that contain the search string. They have windows ME, XP and 2000 systems. Does anyone have...
0
3070
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not want to replace all of them. You need to look at it in a case-by-case basis. What can you do? Answer: emacs.
2
3306
by: rengask | last post by:
I got the code to find and replace within an open text file. ------------------ Private Sub cmdFile_Click() Dim strTemp As String txtFile = "" dlg.FileName = "*.*" dlg.ShowOpen If Dir(dlg.FileName) <> "" Then
7
3055
by: random guy | last post by:
Hi, I'm writing a program which creates an index of text files. For each file it processes, the program records the start and end positions (as returned by tellg()) of sections of interest, and then some time later uses these positions to read the interesting sections from the file.
9
2671
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane T. Smith" "Fred Barzowsky" "Department of Oncology" "Office of Student Affairs" "Lewis Hall" etc. etc. etc. I am wondering what the efficient way...
9
1754
by: Jasper | last post by:
Hi, I have multiple data files which need parsing in realtime so high performance is *crucial*. I dont have a format definition, but from what I can see there is a hierarchy of data. Each data field is named thus <"name":(the <are mine). The data can be quoted text or unquoted text or a composite hierarcy field. Each name/data pair is...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.