Return 1 result from a file that has many

Hello,

I only need 1 line from a file that has “car_departure” however, there are lots of lines with this text.

Is there anyway to chop this down to 1 output. I tried to use the logic from these but then i got a headache.

https://bigfix.me/relevance/details/3002375
https://bigfix.me/relevance/details/2999195

Any help is appreciated.

Here is what i’m running.

preceding texts of lasts "Car_Departure" of lines whose (it contains "Car_Departure") of files ((year of it as string & "_" & month of it as two digits & "_" & day_of_month of it as two digits & "_HME.txt") of (current date - 1 * day)) of folder "C:\Altametrics\HME_Handler\HME_DATA\"

Here is some the result:

4/19/2017,6:20:29 AM,0,0,0,0,0,2,0,0,90,0,0,0,0,0,0,0,0,0,0,115,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,6:27:03 AM,0,0,0,0,0,8,0,0,38,0,0,0,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,
4/19/2017,6:29:15 AM,0,0,0,0,0,1,0,0,31,0,0,0,0,0,0,0,0,0,0,97,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,
4/19/2017,6:30:52 AM,0,0,0,0,0,2,0,0,25,0,0,0,0,0,0,0,0,0,0,93,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,6:41:49 AM,0,0,0,0,0,5,0,0,15,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,7:16:22 AM,0,0,0,0,0,5,0,0,177,0,0,0,0,0,0,0,0,0,0,246,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,7:33:11 AM,0,0,0,0,0,6,0,0,22,0,0,0,0,0,0,0,0,0,0,265,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,7:50:23 AM,0,0,0,0,0,5,0,0,47,0,0,0,0,0,0,0,0,0,0,239,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,
4/19/2017,7:55:49 AM,0,0,0,0,0,8,0,0,59,0,0,0,0,0,0,0,0,0,0,324,0,0,0,0,0,0,0,0,0,0,0,143,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,
4/19/2017,7:56:29 AM,0,0,0,0,0,5,0,0,30,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,217,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,7:58:48 AM,0,0,0,0,0,5,0,0,41,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
4/19/2017,8:14:40 AM,0,0,0,0,0,3,0,0,75,0,0,0,0,0,0,0,0,0,0,250,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,

I got it

preceding texts of lasts "Car_Departure" of lines whose (it contains "Car_Departure" and line number of it <= 2) of files ((year of it as string & "_" & month of it as two digits & "_" & day_of_month of it as two digits & "_HME.txt") of (current date - 1 * day)) of folder "C:\Altametrics\HME_Handler\HME_DATA\"

2 Likes

So this didn’t have my intended affect, it simply just grabs the second line in the file.

Is there a way to get this to grab only 1 line from the file. The line hs to contain “car_Departure” .

If you can determine the line number then request the single line with https://developer.bigfix.com/relevance/reference/file.html#line-integer-of-file-file-line

how about
(preceding texts of lasts "Car_Departure" of lines (minimum of line numbers of lines whose (it contains "Car_Departure") of it) of it ) of files ((year of it as string & "_" & month of it as two digits & "_" & day_of_month of it as two digits & "_HME.txt") of (current date - 1 * day)) of folder "C:\Altametrics\HME_Handler\HME_DATA\"

(I don’t have a debugger handy, but I think that’s along the right lines)

1 Like

Perfect! This is returning a result i expected.

That would be good if the file was static. The issue is, if the device is rebooted it will enter a line for a reboot. If that line happens to be the line i specified, the results will not help us.

Thanks for the link tho, i’m sure i can use that for another analysis.