forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to find text in a file... quickly

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Sat Sep 24, 2005 2:11 am    Post subject: How to find text in a file... quickly Reply with quote

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..


Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Sat Sep 24, 2005 3:14 am    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Sat Sep 24, 2005 6:07 am    Post subject: Reply with quote

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
View user's profile Send private message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Sat Sep 24, 2005 9:00 pm    Post subject: Reply with quote

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.. Confused

Thanks
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Sun Sep 25, 2005 9:07 am    Post subject: Reply with quote

Hi again.

I think you're doing this according to the help file .... which has an error obviously Embarassed

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
View user's profile Send private message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Sun Sep 25, 2005 10:26 am    Post subject: Reply with quote

Ahhhh! Help file error Smile

Thanks for the info.. better that then a code bug Wink

Again String resolved my problem.. now on to the performance test..

Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Mon Sep 26, 2005 12:15 am    Post subject: Reply with quote

Ok Dread.. now works Smile 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.. Smile

So.. will try another solution Smile But it will be fine for my other text files which are smaller in lines...
Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Sep 26, 2005 5:10 am    Post subject: Reply with quote

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
View user's profile Send private message
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Mon Oct 10, 2005 4:08 pm    Post subject: Question on This Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Oct 10, 2005 5:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group