lordsocke Posted October 22, 2015 Posted October 22, 2015 Hi guys I want to copy out all links with a specific beginning from an textfile into another any ideas?
Moderators JLogan3o13 Posted October 22, 2015 Moderators Posted October 22, 2015 Look at the following in the help file:FileReadToArray(filename)For..In Loop (For $element in $aArray) to loop through each line in the fileStringInStr - If StringInStr($element, "mytext") Then DoSomething. "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!
lordsocke Posted October 22, 2015 Author Posted October 22, 2015 the file is about 2mb any more "efficient" solutions?
Moderators JLogan3o13 Posted October 22, 2015 Moderators Posted October 22, 2015 (edited) I parsed a 3MB text file to an array in less than a second, exactly what level of efficiency are you looking to achieve? Edited October 22, 2015 by JLogan3o13 "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!
lordsocke Posted October 22, 2015 Author Posted October 22, 2015 okay maybe im just to noobie to understand it rigth could you explane it better? or give me an example?
Moderators JLogan3o13 Posted October 22, 2015 Moderators Posted October 22, 2015 (edited) Something like this? Finishes in just over a second for me on a 3MB file full of URLs.#include <Array.au3> #include <FileConstants.au3> $sFile1 = FileOpen(@DesktopDir & "\1.txt", $FO_READ) $sFile2 = FileOpen(@DesktopDir & "\2.txt", $FO_APPEND) Local $aArray = FileReadToArray($sFile1) For $element in $aArray If StringInStr($element, "aslpro.com") Then FileWriteLine($sFile2, $element) Next FileClose($sFile1) FileClose($sFile2) Edited October 22, 2015 by JLogan3o13 "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!
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