xdp22 Posted October 24, 2010 Share Posted October 24, 2010 Hello i have one ask, is this possible to : When i got 2 files - file1.txt and file2.txt This files got many lines, example : file1.txt login1 login2 login3 login4 file2.txt login5 login6 login1 login2 See that? in file1 and file2 was line login1 and login2 It's possible to make script what read two txt files, and if txt file has the same line, delete it from ONE txt file? Thanks sorry for bad englisch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2010 Moderators Share Posted October 24, 2010 (edited) xdp22,Hello again! I would suggest using _FileReadToArray to get the 2 files into 2 arrays. Then moving through each array in turn, delete any double entries.See what you can come up with - I will have a go myself and we will see which you prefer. M23Edit:Her is my version if you get stuck:#include <File.au3> #include <Array.au3> Global $aArray1, $aArray2 _FileReadToArray("File1.txt", $aArray1) _FileReadToArray("File2.txt", $aArray2) _ArrayDisplay($aArray1) _ArrayDisplay($aArray2) ; Look at each element of array 1 in turn For $i = 1 To $aArray1[0] ; Work through the second array backwards or the indexing will error For $j = $aArray2[0] To 1 Step -1 ; And see if the same element exists in array 2 If $aArray2[$j] = $aArray1[$i] Then ; If it does, delete it and reduce the count _ArrayDelete($aArray2, $j) $aArray2[0] -= 1 EndIf Next Next _ArrayDisplay($aArray1) _ArrayDisplay($aArray2) ; Finally, use _FileWriteFromArray to rewrite the files, but be careful about the [0] count element Edited October 24, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted October 24, 2010 Share Posted October 24, 2010 (edited) Have a look below at post #8Br,UEZ Edited October 25, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
xdp22 Posted October 25, 2010 Author Share Posted October 25, 2010 Thanks for both users, but i need have it "automatic" cuz in this text files is near 60 000 lines Link to comment Share on other sites More sharing options...
Tvern Posted October 25, 2010 Share Posted October 25, 2010 Thanks for both users, but i need have it "automatic" cuz in this text files is near 60 000 lines What do you mean with automatic? Do you want to monitor the files all the time and correct them constantly? Do you mean writing back to the files automatically?You'll have to put some effort in yourself. The provided examples are already almost fully functional.If you get stuck modifying them to your needs you'll have to explain how you are trying to modify them, and what you have tried that doesn't work. Link to comment Share on other sites More sharing options...
Spiff59 Posted October 25, 2010 Share Posted October 25, 2010 Here my version: That version does have a problem in that given this input: Local $a1[5] = ["login2", "login12", "login3", "login4", "login7"] Local $a2[5] = ["login5", "login6", "login1", "login2", "login8"] The "login1" entry will cause the "login12" entry to be removed. Link to comment Share on other sites More sharing options...
GEOSoft Posted October 25, 2010 Share Posted October 25, 2010 (edited) Code removed. See post #9 Edited October 25, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
UEZ Posted October 25, 2010 Share Posted October 25, 2010 (edited) Good catch Spiff59!This should also work if I'm not missed something again :#include <Array.au3> Local $a1[6] = ["login2", "login12", "login3", "login4", "login7", "login11"] Local $a2[6] = ["login1", "login2", "login5", "login6", "login8", "login100"] ;~ Local $a1, $a2 ;~ _FileReadToArray("File1.txt", $a1) ;~ _FileReadToArray("File2.txt", $a2) $aString = _ArrayToString($a1) & "|" $i = 0 While 1 $search = StringRegExpReplace($aString, "(?i)(" & $a2[$i] & "\|)", "") If @extended Then _ArrayDelete($a2, $i) $i -= 1 EndIf $i += 1 If $i = UBound($a2) Then ExitLoop WEnd _ArrayDisplay($a2) ;~ _FileWriteFromArray("File2.txt", $a2)Please test again.Br,UEZ Edited October 25, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 25, 2010 Moderators Share Posted October 25, 2010 Guys, The OP has admitted in an unsolicited PM that he is trying to spam a Polish website (trying 60000 accounts and passwords) with the script of which this is part. I have replied stating that I am no longer helping in this or any other his threads which appear to have a connection. Thought I would pass on the info - up to you to decide your personal course of action. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted October 25, 2010 Share Posted October 25, 2010 I agree M23, this is really bullshit to utilize our help for any criminal activities! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
GEOSoft Posted October 25, 2010 Share Posted October 25, 2010 He is now blocked on my system and I've removed my code. Thanks Big M. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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