Ahoy good sirs.
I'm new to this, had lotsa fun stealing/gluing parts together and somehow it actually works as intended - but..
the most demanding part (below) is super slow reading from a 35 mb .txt
Feels like I've done something horribly wrong, any neat trick to read a few lines in reverse from a big .txt file - faster than 1 min on a ssd?
Thankyou!
;read file backwards, print recent lines of interest
#SingleInstance force
Searchstring := "@From"
numberofhits := 0
numberofhitswanted := 12
;count number of lines
FileRead, f1, logs/Client.txt
StringReplace,OutputVar,f1,`n,`n,useerrorlevel
Lines := ErrorLevel + 1
Loop
{
FileReadLine, lastline, logs/Client.txt, %Lines%
if (Lines < 0)
break
Lines := Lines - 1
IfInString, lastline, %Searchstring%
{
messages =: %messages%`n%lastline%
if numberofhits = %numberofhitswanted%
break
numberofhits := numberofhits + 1
}
}
Gui, Add,Edit,ReadOnly, last line number %a_index%`n%messages%`n`nnumber of hits %numberofhits%
Gui, Show
return
GuiClose:
GuiEscape:
ExitApp
;F10::ExitApp
reading lines reverse from file is too slow
Re: reading lines reverse from file is too slow
Omg using FileReadLine on a 35 MB script. Update your script immediately. I've done a script below. Cheers.
Code: Select all
q::
FileRead, vText, % A_ScriptFullPath
oArray := StrSplit(vText, "`n", "`r")
;MsgBox, % oArray.Length()
Loop, % vCount := oArray.Length()
MsgBox, % vCount " " oArray[vCount--]
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: reading lines reverse from file is too slow
wow yea, that works almost instantly.
TYVM good sir
TYVM good sir
Who is online
Users browsing this forum: Google [Bot], marypoppins_1 and 140 guests