You could also use TF_Find first as that does allow you to use RegEx and for example \b ("word boundary") have it return all lines, and then count the commas and add one to get the total number of occurrences - here an additional space is added in one of the lines but is still counted
Code: Select all
(join`r`n
DisplayName,Username,Office,SNIFSITECODE,ComputerName,IPAddress,Date,Time,OSVersion,SESSIONNAME,SentCount
Mike,Mike1,London,None,TESTPC,10.254.50.6 ,21\01\2021,16:38:16,WIN_7,console,1 ; we count this one too
Mike,Mike1,London,None,TESTPC,10.254.50.6,21\01\2021,16:38:16,WIN_7,console,2
Mike,Mike1,London,None,TESTPC,10.254.50.61,1\01\2021,16:38:16,WIN_7,console,2 ; but skip this one
)
FileDelete, Test_TestFile.txt
FileAppend, % text, Test_TestFile.txt
find:="10.254.50.6"
Lines:=TF_Find("Test_TestFile.txt", ,, "\b" find "\b",0)
Count:=TF_Count(lines,",") + 1
; Count:=TF_Count(TF_Find("Test_TestFile.txt", ,, "\b" find "\b",0),",") + 1 ; one line
MsgBox % Count
The above looks like CSV and although you can use TF it might be finicky as not columns will line up.
If you know the linenumber(s) - which you now do if you use TF_Find, you could simple read those lines
Nnote you can read them in one go using TF_Find as well) and then Loop, parse, CSV or StrSplit to get the 6th column, see TF_ReadLines() to read specific lines, you can pass on the result of the TF_Find above. But you can get the text at the some time if you use TF_Find()
Code: Select all
LinesWithText:=TF_Find("Test_TestFile.txt", ,, "\b" find "\b",0,1) ; note the 1 for ReturnText parameter - https://github.com/hi5/TF#TF_Find
MsgBox % LinesWithText
which you can now parse with a loop, parse, `n + StrSplit
If you need to work with CSV a lot - there is a lib for that
https://github.com/hi5/CSV 