mikell Posted August 22, 2015 Share Posted August 22, 2015 (edited) Sorry for this hospital event, hope it will get well soonFor the tab test , as number of chars differ in both languages (for the same word) StringRegExp should work better than StringInStrAbout the line number if you mean the "67" in "Interface<TAB>67<TAB>오아시스오아시스<TAB><TAB>1.00" , then please try the code belowThis test works on the 10 lines sample files, it compares line numbers and checks tabs only in lines which exist in both filesexpandcollapse popup#Include <Array.au3> $a1 = FileReadToArray("1.txt") $a2 = FileReadToArray("2.txt") ;========================================= #cs http://www.autoitscript.com/forum/topic/164728-compare-2-arrays-with-3-arrays-as-a-result/ compare the 2 arrays : - the line numbers that are only in array $lineNumbers1 go into an array $asd1 - the line numbers that are only in array $lineNumbers2 go into another array $asd2 - the line numbers that are in both arrays go into another array $asd3 #ce Local $lineNumbers1[UBound($a1)] For $i = 0 to UBound($a1)-1 $lineNumbers1[$i] = StringRegExp($a1[$i], '\t+(\d+)\t+', 3)[0] Next ;_ArrayDisplay($lineNumbers1, "$lineNumbers1") Local $lineNumbers2[UBound($a2)] For $i = 0 to UBound($a2)-1 $lineNumbers2[$i] = StringRegExp($a2[$i], '\t+(\d+)\t+', 3)[0] Next ;_ArrayDisplay($lineNumbers2, "$lineNumbers2") Local $sd1 = ObjCreate("Scripting.Dictionary") Local $sd2 = ObjCreate("Scripting.Dictionary") Local $sd3 = ObjCreate("Scripting.Dictionary") For $i In $lineNumbers1 $sd1.Item($i) Next For $i In $lineNumbers2 $sd2.Item($i) Next For $i In $lineNumbers1 If $sd2.Exists($i) Then $sd3.Item($i) Next $asd3 = $sd3.Keys() For $i In $asd3 If $sd1.Exists($i) Then $sd1.Remove($i) If $sd2.Exists($i) Then $sd2.Remove($i) Next $asd1 = $sd1.Keys() $asd2 = $sd2.Keys() ;_ArrayDisplay($asd1, "line numbers in 1 not in 2") ;_ArrayDisplay($asd2, "line numbers in 2 not in 1") ;_ArrayDisplay($asd3, "line numbers in both") ;================================================= ; tab checking Local $errors = "testing..." & @crlf For $i = 0 to UBound($asd3)-1 For $j = 0 to UBound($a1)-1 $test1 = StringRegExp($a1[$j], '\t+(\d+)\t+', 3)[0] If $asd3[$i] = $test1 Then For $k = 0 to UBound($a2)-1 $test2 = StringRegExp($a2[$k], '\t+(\d+)\t+', 3)[0] If $asd3[$i] = $test2 Then StringReplace($a1[$j], @TAB, "") $n1 = @extended ; counts tabs $db1 = StringRegExp($a1[$j], @TAB&@TAB) ; checks if double tab StringReplace($a2[$k], @TAB, "") $n2 = @extended $db2 = StringRegExp($a2[$k], @TAB&@TAB) If $n1 <> $n2 OR $db1 <> $db2 Then $errors &= "error in line # " & $asd3[$i] & @crlf Exitloop 2 EndIf Next EndIf Next Next msgbox(0,"", $errors) Edited August 22, 2015 by mikell Link to comment Share on other sites More sharing options...
CiRc2K5 Posted August 24, 2015 Author Share Posted August 24, 2015 Perfect shows no errors now when run against file 1 and 2. I do get the same error message if file 1 has any extra lines then file 2. Could we fix this or should I just stick to me searching and finding the missing lines and adding them by hand. Thanks 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