Bigfix relevance to read paragraphs

Hi Team,

I have got the content of /test.txt file as below:

Content1:
        Type              = abc
        Range           = 123
        Account         = abc123

Content2:
        Range           = 456
        Account 	      = egf456

Content3:
        Type	      = xyz
         Status           = status123

Requirement:
Need to fetch the paragraphs of the above file containing certain string.

Eg:
Fetch the paragraphs containing “Type” keyword.

Expected Output:

Content1:
        Type              = abc
        Range           = 123
        Account         = abc123

Content3:
        Type	      = xyz
         Status           = status123

I have tried the below relevance:

Q: (substrings separated by "%0d%0a" whose (it contains "Type") of concatenation of lines of file "/test.txt")
A: Content1:        Type              = abc        Range           = 123        Account         = abc123Content2:        Range           = 456        Account      = egf456Content3:        Type      = xyz         Status           = status123

This prints the entire file and not the expected output.

Note: Strings are separated by tabs (%09)

Please let me know where m I going wrong,

Thanks in Advance!

BigFix inspectors support the reading of “ini” file. If you have a chance to generate a standard ini file then it would be very simple as shown in the following example:

[Content1]
Type=abc
Range=123
Account=abc123

[Content3]
Type=xyz
Status=status123

Q:key “Type” of section “Content1” of file “sample.ini” of folder "c:\TEM"
A: abc
T: 0.061 ms

If not then you have to play with the line of file inspector, use a combination of “substring” , “line starting” and “next line” . I can’t provide a precise example that fit your case. May be someone on this forum can be more precise.

1 Like

Parsing paragraphs is not trivial…in fact we had a previous Relevance Challenge that I think may help.

2 Likes

You were close. I think you need to inject a placeholder for your empty lines, concatenate with “|” then break apart on those injections, filter for your “Type” and then breakdown on the “|”

q: concatenation "|" of (if it = "" then "<LINEBREAK>" else it) of lines of file "c:\test\test.txt"
A: Content1:|        Type              = abc|        Range           = 123|        Account         = abc123|<LINEBREAK>|Content2:|        Range           = 456|        Account %09      = egf456|<LINEBREAK>|Content3:|        Type%09      = xyz|         Status           = status123
T: 2.454 ms
I: singular string

q: substrings separated by "<LINEBREAK>"  of concatenation "|" of (if it = "" then "<LINEBREAK>" else it) of lines of file "c:\test\test.txt"
A: Content1:|        Type              = abc|        Range           = 123|        Account         = abc123|
A: |Content2:|        Range           = 456|        Account %09      = egf456|
A: |Content3:|        Type%09      = xyz|         Status           = status123
T: 1.881 ms
I: plural substring

q: substrings separated by "<LINEBREAK>" whose (it contains "Type") of concatenation "|" of (if it = "" then "<LINEBREAK>" else it) of lines of file "c:\test\test.txt"
A: Content1:|        Type              = abc|        Range           = 123|        Account         = abc123|
A: |Content3:|        Type%09      = xyz|         Status           = status123
T: 1.262 ms
I: plural substring

And Finally

q: substrings separated by "|" of substrings separated by "<LINEBREAK>" whose (it contains "Type") of concatenation "|" of (if it = "" then "<LINEBREAK>" else it) of lines of file "c:\test\test.txt"
A: Content1:
A:         Type              = abc
A:         Range           = 123
A:         Account         = abc123
A: 
A: 
A: Content3:
A:         Type%09      = xyz
A:          Status           = status123
T: 0.660 ms
I: plural substring
1 Like

And if I can guess ahead,

q: (it as trimmed string) of following texts of lasts "=" of substrings separated by "|" whose (it contains "Type" and it contains "=") of substrings separated by "<LINEBREAK>" whose (it contains "Type") of concatenation "|" of (if it = "" then "<LINEBREAK>" else it) of lines of file "c:\test\test.txt"
A: abc
A: xyz

Thankyou @brolly33 :slight_smile:
It worked!!