Hey everyone, looking for a little help on this. I am trying to parse a log file and pull out a few pieces of information, and create the computer name from those pieces. The first piece of relevance is pulling the site #, code directly below, and returns 0123, 0124,0125, and 0126
firsts 4 of following texts of firsts "CHG_" of (lines whose (it contains "CAR" and it contains ((month of it as two digits & "/" & day_of_month of it as two digits & "/" & year of it as string) of date (local time zone) of (now-1*day) as string) of date (local time zone) of (now-1*day)) of file "c:\log\Cardir.txt"
I then have another piece of relevance is pulling back the “p” or “b” from before the “.dat” on the end of the file, code below, and returns “p”,“b”,“b”.
lasts 1 of preceding texts of firsts ".dat" of (lines whose (it contains "CAR" and it contains ((month of it as two digits & "/" & day_of_month of it as two digits & "/" & year of it as string) of date (local time zone) of (now-1*day) as string) of date (local time zone) of (now-1*day)) of file "c:\CARdir.txt")
Lastly, I have a third relevance query to pull the files that end in .DAT, code below, and provides a single “DAT”
lasts 1 of preceding texts of firsts ".DAT" of (lines whose (it contains "CAR" and it contains ((month of it as two digits & "/" & day_of_month of it as two digits & "/" & year of it as string) of date (local time zone) of (now-1*day) as string) of date (local time zone) of (now-1*day)) of file "c:\log\CARdir.txt")
I am trying to create the value “PETER” if there is a “p” returned at the end of the line and “BOB” if there is a “b” at the end and concatenate first the site # with either PETER or BOB so that I can gather the device name, ie. 0123PETER
To throw icing on the cake, but if I cannot get this, we can do this manually, if the third query returns a "DAT"
An example of the actual file is below
03/08/2016 05:04 PM 48,997 CAR_0123_20160308_170439_p.dat
03/08/2016 05:04 PM 48,593 CAR_CHG_0124_20160308_170440_b.dat
03/08/2016 05:04 PM 49,098 CAR_CHG_0125_20160308_170438_b.dat
03/07/2016 05:06 PM 8,597 CAR_CHG_0126_20160307_170629.DAT
I was trying to get the first piece by using the below, which gives a singular expression, which I understand, but cannot figure out how to do it properly.
if (lasts 1 of preceding texts of firsts ".dat" of (lines whose (it contains "CAR" and it contains ((month of it as two digits & "/" & day_of_month of it as two digits & "/" & year of it as string) of date (local time zone) of (now-1*day) as string) of date (local time zone) of (now-1*day)) of file "c:\log\CARdir.txt") = p) then "PETER" else "BOB"
Any help is appreciated String parsing makes me sad.