DrewSS Posted November 14, 2014 Share Posted November 14, 2014 (edited) Hello, I've done some concatenation on several excel docs to build 2 unique lists. However, I need take it 1 step farther and get a list of the UniqueMasterList.txt entries that do NOT match any entries in the Existing.txt file. Can someone please point me in the right direction or show me how this may be done? Existing.txtUniqueMasterlist.txt Edited November 14, 2014 by DrewSS Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 14, 2014 Moderators Share Posted November 14, 2014 I would think using a sqlite database, making a unique column for the data you need to be unique would be simplest. This way, only unique data could be entered without the need for tireless looping with a regex or stringsplit method. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kaisies Posted November 14, 2014 Share Posted November 14, 2014 (edited) #include <Array.au3> Local $aListUnique = StringSplit("111-111,222-222,333-333,444-444,555-555,666-666,777-777",",") Local $aListExisting = StringSplit("111-111,333-333,444-444,555-555,777-777",",") _ArrayDisplay($aListUnique) _ArrayDisplay($aListExisting) Local $i, $i2 For $i = 0 to $aListUnique[0] For $i2 = 0 to $aListExisting[0] If $aListExisting[$i2] = $aListUnique[$i] Then $aListUnique[$i] = "" ExitLoop EndIf Next Next _ArrayDisplay($aListUnique) If I understand your question correctly, this would be the cumbersome method. But I get the feeling time isn't of the essence, and this would "get the job done". Any matches found in the Existing array are replaced with "". Edited November 14, 2014 by kaisies DrewSS 1 Link to comment Share on other sites More sharing options...
Solution mikell Posted November 14, 2014 Solution Share Posted November 14, 2014 FileReadToArray then Scripting.Dictionary is the best way #include <Array.au3> Local $a[11] = [1, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12] Local $b[12] = [1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 13, 14] Local $sda = ObjCreate("Scripting.Dictionary") Local $sdb = ObjCreate("Scripting.Dictionary") For $i In $a $sda.Item($i) Next For $i In $b $sdb.Item($i) Next For $i In $sdb If $sda.Exists($i) Then $sdb.Remove($i) Next $asd = $sdb.Keys() _ArrayDisplay($asd, "$asd") DrewSS 1 Link to comment Share on other sites More sharing options...
DrewSS Posted November 14, 2014 Author Share Posted November 14, 2014 Thank you both very much! I've never heard of Scripting.Dictionary but it looks promising. I'm going to try this today! For the StringSplit method, is there an easy way to import each line of the text files as a separate string? And Sm0Ke_N; excellent suggestion, but the users of this wont have sql installed on their PCs so I need to keep it isolated -- like kaisies said, cumbersome isnt an issue here, its just gotta work. The Excel concatenation already takes 90 - 180 seconds (15000 + rows, 8-12 columns per report, 5x excel reports ) Link to comment Share on other sites More sharing options...
DrewSS Posted November 14, 2014 Author Share Posted November 14, 2014 FileReadToArray then Scripting.Dictionary is the best way #include <Array.au3> Local $a[11] = [1, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12] Local $b[12] = [1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 13, 14] Local $sda = ObjCreate("Scripting.Dictionary") Local $sdb = ObjCreate("Scripting.Dictionary") For $i In $a $sda.Item($i) Next For $i In $b $sdb.Item($i) Next For $i In $sdb If $sda.Exists($i) Then $sdb.Remove($i) Next $asd = $sdb.Keys() _ArrayDisplay($asd, "$asd") Wow that was perfect. Thank you so much! 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