usera Posted May 16, 2014 Share Posted May 16, 2014 Greeting, I have 2 files, "FILE1" is the include keyword that I to search in "FILE2" for example "FILE1" keyword1 keyword2 keyword3 keyword4 keyword5 example for "FILE2" blah, blah, keyword1, blah, blah blah blah, keyword2, blahblahblah keyword3, blahblahblah ... how can I write a AU3 to show that FILE2 has keyword1, has keyword2, but not keyword5 Thanks usera Link to comment Share on other sites More sharing options...
jguinch Posted May 16, 2014 Share Posted May 16, 2014 Did you try something ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 16, 2014 Moderators Share Posted May 16, 2014 Are they both flat text files, or is the first like an .ini? Does FILE1 have only that keyword on each line, or other data you would need to sift through? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Damein Posted May 16, 2014 Share Posted May 16, 2014 This should get you started. I advise you to read the help file a bit more, pretty basic stuff. #include <Array.au3> Local $KeyWordArray[6] $KeyWordArray[1] = "Test" $KeyWordArray[2] = "Test2" $KeyWordArray[3] = "Test3" $KeyWordArray[4] = "Test4" $KeyWordArray[5] = "Test5" $File = FileOpen("x") $FileRead = FileRead($File) For $i = 1 To 5 If StringInStr($FileRead, $KeyWordArray[$i]) Then MsgBox(0, "Found", "Found the keyword" & @CRLF & $KeyWordArray[$i]) EndIf Next usera 1 Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
JohnOne Posted May 16, 2014 Share Posted May 16, 2014 Did you try something ? lol Not a chance, not even after 7 years. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 16, 2014 Moderators Share Posted May 16, 2014 I agree with J1, didn't realize you had been here so long, usera. You should know by now to put some effort in before you post. As I worked this up anyway, this is how I would do it as opposed to Damein's method. $aFile1 = FileReadToArray(@DesktopDir & "\FILE1.txt") $aFile2 = FileReadToArray(@DesktopDir & "\FILE2.txt") For $keyword In $aFile1 For $line In $aFile2 If StringInStr($line, $keyword) Then MsgBox(0, "", $keyword & " found!") Next Next usera 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 I agree with J1, didn't realize you had been here so long, usera. You should know by now to put some effort in before you post. As I worked this up anyway, this is how I would do it as opposed to Damein's method. $aFile1 = FileReadToArray(@DesktopDir & "\FILE1.txt") $aFile2 = FileReadToArray(@DesktopDir & "\FILE2.txt") For $keyword In $aFile1 For $line In $aFile2 If StringInStr($line, $keyword) Then MsgBox(0, "", $keyword & " found!") Next Next thanks, do not know how to do it, that is why ask any way thanks usera Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 This should get you started. I advise you to read the help file a bit more, pretty basic stuff. #include <Array.au3> Local $KeyWordArray[6] $KeyWordArray[1] = "Test" $KeyWordArray[2] = "Test2" $KeyWordArray[3] = "Test3" $KeyWordArray[4] = "Test4" $KeyWordArray[5] = "Test5" $File = FileOpen("x") $FileRead = FileRead($File) For $i = 1 To 5 If StringInStr($FileRead, $KeyWordArray[$i]) Then MsgBox(0, "Found", "Found the keyword" & @CRLF & $KeyWordArray[$i]) EndIf Next thank you very much! Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 Are they both flat text files, or is the first like an .ini? Does FILE1 have only that keyword on each line, or other data you would need to sift through? Thanks for ask both flat text, yes, FILE1 have only that keyword on each line Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 16, 2014 Moderators Share Posted May 16, 2014 Have you tried what I posted? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Solution jguinch Posted May 16, 2014 Solution Share Posted May 16, 2014 Now, ask yourself the question whether you want the keyword "test" to be found in the string "testing". And so, do not use StringInStr... #Include <Array.au3> Local $aKeywords = FileReadToArray("file1.txt") Local $sContent = FileRead("file2.txt") Local $aResult[ UBound($aKeywords) ][2] For $i = 0 To UBound($aResult) - 1 $aResult[$i][0] = $aKeywords[$i] $aResult[$i][1] = StringRegExp($sContent, "\b" & $aResult[$i][0] & "\b") ? "found" : "not found" Next _ArrayDisplay($aResult) usera 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 Have you tried what I posted? yes, I did, but no result Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 (edited) Now, ask yourself the question whether you want the keyword "test" to be found in the string "testing". And so, do not use StringInStr... #Include <Array.au3> Local $aKeywords = FileReadToArray("file1.txt") Local $sContent = FileRead("file2.txt") Local $aResult[ UBound($aKeywords) ][2] For $i = 0 To UBound($aResult) - 1 $aResult[$i][0] = $aKeywords[$i] $aResult[$i][1] = StringRegExp($sContent, "\b" & $aResult[$i][0] & "\b") ? "found" : "not found" Next _ArrayDisplay($aResult) "You want the keyword "test" to be found in the string "testing" it should not happend. it Works!, thanks Edited May 16, 2014 by usera Link to comment Share on other sites More sharing options...
usera Posted May 16, 2014 Author Share Posted May 16, 2014 lol Not a chance, not even after 7 years. LOL, still learning Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now