Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

Monarch question

I'm not sure if I am in the right area, but I have a question regarding the Monarch software.

Is it possible to extract lines from a report based on what the previous line has in it?

For example, I wish to extract only those lines that have the 1st 5 characters as "TOTAL", but the line above it must either be blank or have an underscore (_).  Is this possible?

  • 3
  • 2
1 Solution

While monarch does allow you to use multi-line templates, it doesn't allow you to specify the trap on both of the lines.  What I've done in similar situations is use one trap on both lines (or in your case, two traps on both lines, one for _ and one for blank), make sure "Trap line" is 1, getting what you need from line 2.  Then use an append trap for just line two when TOTAL appears, and only use the data where the values match from both traps (though for you it would be if _ and TOTAL values match, and blank and TOTAL values match).

Extracting some of that data would be possible with a handwritten program (not monarch), though it may not be worth the trouble of creating it, when you can use the workaround above.

To show you what I mean, I'll assume you want the 3 characters after TOTAL.  For my example I'll say the trap name for the 3 characters after total on the line after a blank line is VAR1, the trap name for the 3 characters after a _ line is VAR2, and the trap name for the 3 characters after TOTAL is VAR3. So if a portion of your file looked like:





Your table (using | as the column separator) would look something like
VAR1  |  VAR2  |  VAR3
123    |            |  123
234    |            |
         |  345     |   345
         |  RAN    |
456    |            |  456

You would only want cases where VAR1=VAR3 or VAR2=VAR3, which would be lines 1, 3, 5.  All 5 lines would have to be exported, and in the exported file (probably excel or csv for the first pass) you would have to delete the lines when they dont match.

Again, not an easy solution, but monarch didn't make this situation easy to deal with.
mak345Author Commented:
From above:

make sure "Trap line" is 1, getting what you need from line 2.

How do I go about doing that?
Open the file in monarch, and view the Report (ie not table or summary).  Highlight the 2 lines that can contain the pattern, and go to Template / New Template.
There is a setting called "Trap Line" (to the right of Ok / Cancel), make sure that is listed as 1.
In the line where you define the trap (Has an underlined "R" to the left of it), put an underscore in the location yours is in on line 1.  In the box below it (has an underlined "S"), highlight the portion on the second line that you want to take.  Right-click it, add the name, and click ok (normal trap/pattern defining procedure).  
This way it will look on both lines, and only take the part of the second line when line 1 has the underscore.

Make sense?
mak345Author Commented:
When I do this, it highlights anything with an underscore and the characters below it.  However, I want anything with an underscore & only those lines that have "TOTAL" below it.  Possible?
Not in one trap.  You'll have to use 2 templates, one for the underscore and another for the total, and when the 2 values are the same then you know it met both criteria.  Unfortunately it is the only way to do it in monarch, since it doesnt allow you to use multi-line patterns (ie underscore on line one and total on line two). It might be possible you can do it in the newest version which I haven't used, but when I looked on their website and related forums, I saw nothing that suggested it is possible yet.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now