Is there any efficient way to find a string in a file?

I have a large file. Till now, the only way I know to search a string in it 
is to load the entire file in memory, and then compare them word by word. 
It works but also inefficient. Could you tell me a better way?
Thanks.
0
all (10)
11/4/2003 9:52:21 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
377 Views

Similar Articles

[PageSpeed] 31

hi,
   If memory is a constraint you can try using memory mapped files. As 
far as searching for a string is concerned, you might want to consider 
the boyer moore algorithm.
hth
gangadhar npk
mizi wrote:
> I have a large file. Till now, the only way I know to search a string in it 
> is to load the entire file in memory, and then compare them word by word. 
> It works but also inefficient. Could you tell me a better way?
> Thanks.


0
11/4/2003 11:33:14 AM
Hi,

there are several algos that implement look ahead and run faster than a
naive algo does.

As far as the file being in memory goes, you could open the file pointer
read part of it into memory, advance the file pointer, examine that memory,
clear the memory and then read some more etc.

regards,
- sami

"mizi" <all@ywzc.net> wrote in message
news:Xns94296413A566Ballywzcnet@207.46.248.16...
> I have a large file. Till now, the only way I know to search a string in
it
> is to load the entire file in memory, and then compare them word by word.
> It works but also inefficient. Could you tell me a better way?
> Thanks.


0
a
11/4/2003 1:56:22 PM
Reply:

Similar Artilces:

Is there a way in Excel to insert a picture into a group of merge.
Is there a way to insert a picture into an Excel spreadsheet and have the picture auto fit into a grop of merged cells? Or do I have to manually resize the picture every time? hi, not possible. image controls are objects that "float" on top of the sheet. they cann't be assigned to cells. you can set the size. size the format control to the size you want it. Right click the image control, click properties. set the autosize to false. Regards Frank. >-----Original Message----- >Is there a way to insert a picture into an Excel spreadsheet and have the >picture auto ...

No pst listed in Outlook 2007 "import a file"
I need to import data from an Outlook PST file stored elsewhere on my computer. When in Outlook 2007 I use: File/Import and Export/Import and Export Wizard/ Import from another program or file/ ..... now there is no vertical slider bar fro me to move down to select "pst file". Some lines of text in this Import a file window are truncated at the right hand side and to me it looks as if the text font is larger than normal. Hope someone can assist? regards, "nobody" You never use import to transfer data form a native file. Just open it to get what you need. --...

Opening Money 2001 backup file
I recently had to reformat my PC, and reload all the software. When I try and open my money backup file, I'm prompted for a password, which I don't know. How can I get the program to open the backup file? In microsoft.public.money, Tom wrote: >I recently had to reformat my PC, and reload all the >software. When I try and open my money backup file, I'm >prompted for a password, which I don't know. How can I >get the program to open the backup file? See http://umpmfaq.info/faq.html#Q152 ...

most efficient way for multiselect in datagridview
Hi, I would like to be able to multi select rows in a datagridview, just by clicking a cell in the rows I need. The code below, does work. But it looks like it might not be the most efficient way to do this. When I run the program and select rows, the datagrid does not really instantly change, but you can see it changing. It's kind of slow, while my machine is not slow at all. Is there a more efficient way to do this? Can I let the datagrid stop from updating, till the foreach loop is done and then start updating again? If so, how can I stop the datagrid from updating / refreshi...

copy file in lan
Hi, i need some help i dont know how to copy files in lan where i have to insert the password , how can i insert the passowrd and the user programaticly. my purpose is to create a backup of some files from many computers in our company some pc are runing with win98 thanks for help i think i get my answer i must use WNetAddConnection3(...) "mido1971" wrote: > Hi, > i need some help > i dont know how to copy files in lan where i have to insert the password , > how can i insert the passowrd and the user programaticly. > > my purpose is to create a...

how to plot efficient frontier
How to plot efficient frontier from sets of data containing expected return, average return, variance, standard deviation, covariance and correlation ? ...

Converting money files to/from US
Can an International Money file be converted to US? If it can, can it be converted back to International? I am going to work in the US for a year and want to use the US version while there and use Money for PocketPC, then when I return, go back to the :local" version. TIA Not easily. But you can export the accounts from one version and import into a different one using QIF. You only will get the account registers, not any scheduled bills/deposits, budget etc. See http://money.mvps.org/faq/#ImportExport -- Glyn Simpson, Microsoft MVP - Money http://money.mvps.org Check http...

quickest way to populate hyperlinks
Wondering the best way to set up files to quickly populate the table/form for a products table that has hyperlink fields. Some examples of the fields are prod.id(text) MSDS(hyperlink), Specsheet(hyperlink),etc. there are at least 15 hyperlink fields for each prod. Do I have to right click on each record of each field an got to Edit hyperlink to go get the file - any quicker way???? thanks, barb Dear Babs: Download the applet that I put together to demonstrate a hyperlinks ListBox at http://www.emrupdate.com/files/folders/al_borges/entry58232.aspx Cheers, Al "babs" wrot...

permissions on .pst files
I am creating .pst files using EXMERGE. Is there a way to remove permissions or to create them without permissions so that anyone could import the .pst into their Outlook? Phil On Tue, 1 Nov 2005 14:21:06 -0800, Phil AAMA <PhilAAMA@discussions.microsoft.com> wrote: >I am creating .pst files using EXMERGE. Is there a way to remove permissions >or to create them without permissions so that anyone could import the .pst >into their Outlook? >Phil A user should be able to import a pst into their own mailbox assuming they have the correct file perms. In news:2A0A26E9-...

Phantom LightningSand.CFD file
My system keeps getting disk errors on a file : \Documents and Settings\All Users\Application Data\Norton\{0C55C096-0F1D-4F28-AAA2-85EF591126E7}\Norton\SRTSP\LightningSand.CFD (always the same index # 30) I have no idea about where that file comes from. In fact, the file is NOT there just before system shut down.... But it is still in error before booting. It happens once or twice a week... I now don't think the file has anything to do with Norton, but I do not find any viruses with 5 different tools !! Many messages on the web refer to that file as 'locked', which...

hi tom how do i find my myspace message?????
From: "Tom" <Tom@discussions.microsoft.com> Subject: Access DLL Error/VBA Error Date: Sunday, February 28, 2010 11:43 AM I am having a hudge issue with Access 2007 that is preventing me from programing in VBA and am REALLY hoping someone can help. There are at least two issues. If I add a control and the control wizard is selected, I get the "Error in Loading DLL" error and cannot use the wizard. Also, if I open VBA, and type "me." into the module, as soon as I type the period, Access and VBA crashes. I have deselected the references to Micros...

Publisher File gets big
Hi there, no matter whether I insert a graphic into a Publisher File or link it to the file, the Publisher File always grows more than 3 mb with each graphic. Shouldn't there be a difference between a linked file and an imported file? I work with Publisher 2000 and Windows XP Thanks After managing to set up OE-QuoteFix on his new PC, Ed reads a message from Klaus-Uwe Krieger <Klaus-Uwe.Krieger@epost.de>... > no matter whether I insert a graphic into a Publisher File or link it > to the file, the Publisher File always grows more than 3 mb with each > graphic. This is a kn...

find question
how do i find information in a workbook? i've tried selecting all the sheets but only seems to finf results in the first sheet i need to seach the whole workbook many thanks steve You may find this very useful. Try Jan Karel Pieterse's FlexFind: http://www.bmsltd.ie/MVP/ Steve Goodrich wrote: > > how do i find information in a workbook? > i've tried selecting all the sheets but only seems to finf results in the > first sheet > i need to seach the whole workbook > many thanks > steve -- Dave Peterson ec35720@msn.com ...

what is the best way to do this (replacing xmlnode value)
i need to copy several xml files and use it as xml element and insert them into a xml file. i use DOM support in .Net and from the pervious help i was able to copy and insert them into the xml file that i want but i need to change some xml node value before i insert. what is the best way to do this? dotnetnoob wrote: > i need to copy several xml files and use it as xml element and insert them > into a xml file. i use DOM support in .Net and from the pervious help i was > able to copy and insert them into the xml file that i want but i need to > change some xml node value ...

Best Way to Create Toggles
What's the best way of creating toggles. For example, want to have the user select Yes or No and make cells do calculations based on the answer. Any useful hints from web sites? thanks One way follows below..............There are many methods and "best" is a subjective term that will differ depending upon whichever ox is getting gored. Select A1 and Data>Validation>Allow>List In "Source" box type in yes,no with the comma and no spaces In B1 enter this formula =IF(A1="Yes",SUM($D$1:$D$10),SUM($E$1:$E$10)) Click on A1 and choose yes or...

Efficient Formula?
Hi, I'm new to this newsgroup and newsgroups in general and I hope its ok to add snapshots to posts.... I created a sheet a while back part of which showed a monthly snapshot of when staff were working. The issue I had was that staff worked on a rotating 4 week roster not a monthly roster and it took me quite some time to get it right. As I said I've only just recently started using this newsgroup and have seen some very advanced and inventive solutions to problems. As such my question is this. Could I have achieved the results below using a more efficient formula or metho...

Best way to make name tags?
I need to set up a template for some name tags to be 3.5" by 2.5". Is there an easier way to do this besides messing around with text boxes? I was trying to do it through the Custom Publication through Page Setup, but then they all have to be exact same and I can't change the names for each tag. I don't have any special paper or anything, just the measurements that they need to be. Any thoughts or guidance would be very much appreciated! Are you planning a mail merge so each name tag will be different? If you plan to print many tags on a page and cut them yourself, your...

After installing SP2 for office 2007 can't open some excel files
I upgrade from office 2003 to 2007 and had no problem all files would open some needing to be converted but everything was great. Once i installed SP2 excel files that user's download from a site don't open anymore. They open fine for user that are still on SP1. There was a similiar issue with publisher and a fix was created. Is there going to be a hotfix for Excel also? Has anyone else seen this issue? ...

Files for printing
I am putting together a booklet which is going to be printed at a commercial printers. The printer doesn't know Publisher but said it will be fine if I save it to a pdf and save all images to cmyk format. My question is, do I need to save all the jpg's etc. to cmyk format and put them back in - or can I simply save the file in the print options to 'output composite cmyk'? This is a regular 40 page booket that I am getting printed so I want to make my life as easy as possible! Many thanks Sorry - forgot to mention - using Publisher 2003 "ChrisB" <chis@w...

How to recover data from OL2003 OST file when Exchange Server is no longer available
Hello After Exchange Server (in Windows Small Business Server 2003) is no longer available, I still have an OST file (created in OL 2003), just under 2 GB in size. Can one recover the data from this OST file? Thanks, David Yes, you can get the data out of it. Do you still have the exchange profile or very recently deleted it? if so, it's a matter of moving the stuff to a pst. If not, you need a tool - see http://www.slipstick.com/outlook/ansi-to-unicode.asp and http://www.slipstick.com/problems/repair2gbpst.asp for tools that you can use. -- Diane Poremsky [MVP - Outlook] O...

restore calendar from pst file
I unfortunately backed up the Calendar folder as a .pst file and now when I try to import it back to Calendar I cannot - error message is that it is incorrect format. It needs to be a .ics file - what can I do to restore the data to my Outlook Calendar? ...

Ending Balance way off
My ending balance shows there are thousands of dollars more in my checking account than there actually are. I had Monday set up to automatically download my statement from my bank. At the time, it shows a bank balance close to what actually exists in my account with the Ending Balance being way off. I've since turned off automatically downloading my bank statement. Since then, the Bank Balance has disappeared from my register, but the Ending Balance is still way off. Scott wrote: > My ending balance shows there are thousands of dollars more in my > checking account than t...

All Excel files opening in same window
Hi, I have a problem where opening different excel files, opens in the same window. I don't mean showing each file in a column (I am using XP), but all files using the same window, and no other files showing. To go between each file, I can use CTRL+TAB but would prefer to have excel show files as it used to-in columns, so I can select which one I want to open this way. Any ideas on how I get this option back? Thanks Greg Matthews Go to Tools>>Options>> View and check the option "Windows in Task Bar" Karthik ...

Find problem
Hi using 2007 I'm using the search function for the word mins (short for minutes) through a 160 page booklet to put a period after it. When I find an entry that needs editing & fix it or paste a correction, then click to find the next entry, the search window keeps returning to the first page and I can't finish making corrections I know there are more errors to fix as a manual search finds them Anyone know how to make the search function continue on after I have made a correction please? -- Martin ���� Try editing the story in Word. -- JoAnn Paules MVP Microsoft [Publisher]...

Convert Outlook Express files (DBX) to Outlook 2000 files (PST)
I have four years worth of e-mails backed up and stored from when I used Outlook Express, these files are saved as DBX. I want to covert these to PST files so that I may one day view them in the current version of Outlook. I don't want to import the DBX files into my current outlook because I am afraid of two things: I don't want to comibe this information and the file size will be extremely large. How can I convert the DBX files (Outlook Express mail) into PST Files (Outlook 2000)? Also, can I do the same with the Address Book File of Outlook Express? Thanks, Frank &quo...