| View previous topic :: View next topic |
| Author |
Message |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Sat Sep 24, 2005 2:11 am Post subject: How to find text in a file... quickly |
|
|
Hi,
I have a text file containing about 100,000 lines.
I want to search in that file an exact text match, but it has to be extremely quick, cause the app must continue...
So far I tried using
- the VDS list and @match.. No way! VDS crashes...and its slow
- vdslist.dll. Fast lightning.. BUT, when the text is loaded in a list my app takes way too much memory.. (25 megs!)
- Tried string.dll, I used the @string(RegxRepInFile...), works well but a bit slow.. takes 2 secs at each new search..
Now, anyone has any other idea please?
Thanks in advance..
 |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Sat Sep 24, 2005 3:14 am Post subject: |
|
|
Well.. here is one solution I found for Windows XP and 2000...
I use this:
| Code: | runh findstr.exe /i "myword" @shortname(@path(%0)mybiglist.txt),PIPE,wait
%%result = @pipe() |
But.. i would like to a VDS solution.. and that works on other Windows..
The normal FIND.exe that comes with all Windows.. is rather slow on my 100,000 lines txt file  |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sat Sep 24, 2005 6:07 am Post subject: |
|
|
If you just wanna check whether the string is there or not - have you tried @FileOps(StringCount....) in String.DLL?
Should be pretty fast.
If you need to extract the line, then the next version of String.DLL has a new MatchLines function that will make
a new file containing the lines matching a search string. I could make a faster release if necessary.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Sat Sep 24, 2005 9:00 pm Post subject: |
|
|
Thanks Dread.. but I am having a problem with your suggestion..
I tried this:
| Code: | %%file = @shortname(@path(%0)mytest.txt)
%%match = = hello
# info %%file @cr()%%match
info @string(fileops,StringCount,%%file,%%match,exact,,,) |
the file mytest.txt contains only:
hello
world
test
I always get 0 as the result.. even if I try to find hello or any of the other choices..'
In the help file I see:
@string(FileOps, StringCount, [input file], [search string],[EXACT],,,)
So I am wondering what I am doing wrong..
Thanks |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Sep 25, 2005 9:07 am Post subject: |
|
|
Hi again.
I think you're doing this according to the help file .... which has an error obviously
As there's no output file, your search string must be moved 1 pos to the right. Correct syntax:
StringCount: @string(FileOps, StringCount, [input file],,[search string],[EXACT],,)
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Sun Sep 25, 2005 10:26 am Post subject: |
|
|
Ahhhh! Help file error
Thanks for the info.. better that then a code bug
Again String resolved my problem.. now on to the performance test..
 |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Mon Sep 26, 2005 12:15 am Post subject: |
|
|
Ok Dread.. now works Thanks..
But there is a performance issue when I tried with PII 400 MHZ.. it took about 10 - 15 seconds before finding the match in the 100,000 lines if text..
But hey , its an old PC and Win 98..
So.. will try another solution But it will be fine for my other text files which are smaller in lines...
 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Mon Sep 26, 2005 5:10 am Post subject: |
|
|
Hey
I'm glad it works for ya.
And I wouldn't perhaps call it a performance issue... that's a really slow computer - you can do nothing
'bout that.
Just made a test on my 3 years old 2.0 Ghz box: 0.8 sec to complete that operation with an 18 MB/97,000 lines file.
It takes 8 secs just to load that file into a VDS list.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
webdaddy Contributor


Joined: 14 Nov 2004 Posts: 151 Location: Raleigh NC
|
Posted: Mon Oct 10, 2005 4:08 pm Post subject: Question on This |
|
|
I have a file that has informtion such as this in it.
TEST|2134.2341.234.23423|LOCATION|435kdf4
Im my application I have a variable %A that contains the second field.
What I want to do is use string.dll to confirm that the file contains %A and if it does then I need to get the value of the first column (in this example TEST). Im having a brain freeze this morning and cant remember how I did this before.
WD _________________ K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux... |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Mon Oct 10, 2005 5:30 pm Post subject: |
|
|
You could use String.DLL's FileOps-stringcount function to make sure whether the file holds your
search string.
To obtain the content of column 1 you could use PARSE (VDS native) or String.DLL's getbefore or parse function.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
|