ahmeddzcom Posted February 21, 2022 Posted February 21, 2022 (edited) Hello 1.txt = 33004: SPI 33005: SPPO 33006: VISQ 33007: BRI 33007: BIG 33117: TOR 33118: TOR 50 33120: DA 33122: TA 320 33122: 320 33407: TISK 33408: A 150 33410: TIKA 33413: TISKA 32 P ============== 2.txt = 33004 30001 33007 33117 33118 30010 30510 ============== i need the Common result = 33004 33007 33117 33118 (FileReadLine is so slow when i have 3000 line) Edited February 21, 2022 by ahmeddzcom
Zedna Posted February 21, 2022 Posted February 21, 2022 Use 2x FileRead() + StringSplit() + StringInStr() or FileReadToArray() Resources UDF ResourcesEx UDF AutoIt Forum Search
ahmeddzcom Posted February 21, 2022 Author Posted February 21, 2022 i use this but i can't get result expandcollapse popup#Include <Misc.au3> #include <File.au3> #include <StringConstants.au3> FileDelete("TAXExxx.txt") If FileExists("TAXExxx.txt") Then Exit MsgBox(0,"","TAXExxx.txt _ not del") Local $P1 = "P1.txt" Local $P2 = "P2.txt" Local $TX1 = "TX1.txt" Local $TX2 = "TX2.txt" Local $TX3 = "TX3.txt" For $y = 1 to _FileCountLines($P1) Local $sStringP1 = FileReadLine($P1, $y) Local $sStringP2 = FileReadLine($P2, $y) ;~ MsgBox(0, "", $sStringP1&"_"&$sStringP2) For $i = 1 to _FileCountLines($TX1) ;~ MsgBox(0, "",$i) Local $sStringTX1 = StringLeft(FileReadLine($TX1, $i), 5) Local $sStringTX2 = StringLeft(FileReadLine($TX2, $i), 3) ;~ MsgBox(0, "",$sStringTX1&"_"&$sStringTX2&"_____"&FileReadLine("TX3.txt", $i)) If $sStringP1&"_"&$sStringP2 = $sStringTX1&"_"&$sStringTX2 Then ;~ MsgBox(0,"",$sStringP1&"_"&$sStringP2) ;~ FileWrite("TAXExxx.txt",$sStringP1&"_"&$sStringP2&"_____"&FileReadLine("TX3.txt", $i)&@CRLF) FileWrite("TAXExxx1.txt",$sStringP1&@CRLF) FileWrite("TAXExxx2.txt",$sStringP2&@CRLF) FileWrite("TAXExxx3.txt",FileReadLine("TX3.txt", $i)&@CRLF) EndIf Next Next Beep(2000,200)
Solution Nine Posted February 21, 2022 Solution Posted February 21, 2022 (edited) Or : #include <Array.au3> Local $t1 = FileRead("T1.txt") Local $t2 = FileRead("T2.txt") $t2 = StringReplace($t2, @CRLF, "|") $a = StringRegExp($t1,"(" & $t2 & ")", 3) $a = _ArrayUnique($a) _ArrayDisplay($a) It could be done in a single line $a = _ArrayUnique(StringRegExp(FileRead("T1.txt"), "(" & StringReplace(FileRead("T2.txt"), @CRLF, "|") & ")", 3)) Edited February 21, 2022 by Nine ahmeddzcom 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
SOLVE-SMART Posted February 21, 2022 Posted February 21, 2022 Hi @Nine, the idea of replacing \r\n with a "|" pipe for using in the RegEx pattern is quite awesome, I like it 👍 . For the file examples of @ahmeddzcom, absolutly valid and nice, as long as the file will not contain a pipe. Then it could come to an invalid verification 🤔 . Anyway, I am impressed because I did such things in a way more complex style in the past, which is obviously not needed 😀 . Best regards Sven ________________Stay innovative! ahmeddzcom 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Nine Posted February 21, 2022 Posted February 21, 2022 Just curious, how fast is it with 3k lines ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
SOLVE-SMART Posted February 21, 2022 Posted February 21, 2022 Hi @Nine, this depends more on the line width (amount of characters on the line). I tested it with around 3k lines and after two seconds the result is displayed. If I increase the line width to do a harder comparison it will take several times longer. But still okay in my opinion 😅 . Best regards Sven ________________Stay innovative! ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
ahmeddzcom Posted February 22, 2022 Author Posted February 22, 2022 Hello @Nine 17 hours ago, Nine said: Just curious, how fast is it with 3k lines ? Time taken = 0.01 secs with 10k lines
Nine Posted February 22, 2022 Posted February 22, 2022 5 minutes ago, ahmeddzcom said: Time taken = 0.01 secs with 10k lines ahmeddzcom 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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