When and How to Use the Three Trap Types in Altair Monarch

Apr 16, 2025

Altair Monarch is the natural choice for a data scientist to acquire, process, cleanse, and format a wide range of data from any number of structured or unstructured sources. One of the most prominent features of the software lies within its Trapping ability. In Altair Monarch, a trap is a user defined template that searches through your input data for matching conditions. Based on the type of trap, how it is defined, and the input data, this will determine what results are populated in the report table when you have concluded your data extraction. These traps can be set up to look for certain combinations of alphanumeric characters in certain locations on the input document, and they can range from very broad to extremely specific. Figure 1 below shows the screen where users select between the three main types of traps in Altair Monarch: Standard, Floating, and Regex.

Fig 1. Trap selection menu in Altair Monarch.

To demonstrate how to use these trap types, we will use a dataset that may be familiar to some of you. Previously, we published a blog series and a video showcasing another tool, Altair AI Studio (previously Altair RapidMiner), and how we can use it to predict the future value of Lego sets. For this Altair Monarch demonstration, we will use the raw HTML data that was scraped from the Internet. Each HTML page was saved as a text file, and it contains all the information regarding the statistics and history of a given Lego set, and we will use Monarch to extract and structure that data!

 

Standard Traps

Standard Traps are the most common types of traps in Altair Monarch, and they are likely what you will start with when you first open your data source in Report Design mode. These are useful when you know exactly where your data of interest is in your input file. By that, I mean that the indentation for a given field is the same across all inputs. In our Lego HTML file, we can use one of the early references to the Set Number as an example. Figure 2 below shows that I know a few things:

  • The exact text that precedes the Set Number
  • The exact length of the Set Number
  • The exact indentation (how far from the left edge of the document) of the Set Number

Fig 2: Example of Standard Trap.

Knowing all this information makes this a prime candidate for a Standard Trap. This is the most basic way of trapping information in Altair Monarch, and it is often enough to extract everything that users need. Figure 3 below shows the sample report from the first input file; I have named the field Set Number – Standard because we will be using Set Number again in the next section.

Fig 3: Report output after creation of Standard Trap.

 

Floating Traps

Floating Traps are slightly more advanced than Standard Traps. Functionally, they are almost the same as each other, apart from indentation; Standard Traps require the same level of indentation for each capture, while floating traps do not. Other than that, though, we can set up our Floating Traps in basically the same manner. Figure 4 below shows an example use case of a Floating Trap to capture the Set Number. A Floating Trap is needed on this particular line because the text before it contains the set name, which varies in length, meaning the Set Number could start anywhere. However, we do know what text immediately precedes it, and we know the length, so we can still provide that as our Floating Trap setup.

Fig 4: Example of setup of Floating Trap

Again, shown in Figure 5, we successfully captured the Set Number from a different location using a different trapping method! Most data scientists probably will not be extracting the same field twice, but this just goes to show that Altair Monarch offers users an extensive array of methods to accomplish their goals and accommodate their needs.

Fig 5: Report output after creation of Floating Trap.

 

Regex Traps

Finally, Regex Traps, whose name comes from Regular Expression, are the most advanced form of traps in Altair Monarch. Regex Traps allow users to enter any regular expression as a trap template, which will then search the input file for any matching criteria. In this example, I wanted to acquire the Set Name. There was a line that I knew I could find this on, but it started at a different indentation level across each input file, and the length of the Set Name varied from file to file, meaning Standard and Floating traps would not suffice.

Since I know that the Set Name is preceded by the following string: “name”: “, AND since I know it is followed by an additional quotation mark, I can write a Regular Expression to search for text between “name”: “ and a quotation mark: “name”: “([^”]+)”. Figure 6 below shows that once this Regex Trap is created, Altair Monarch automatically highlights any matching text, which is the Set Name, as desired.

Fig 6. Example setup of Regex Trap

From here, all we need to do is to right click matching text, and we can directly create a new field from this capture. This will add the Set Name to our report with the other fields we have already trapped. This Regex Trap allowed us to pull out very specific information from our input data, where Standard and Floating traps would not have been suitable for the job.

Fig 7: Field creation from Regex Capture

Altair Monarch offers users multiple ways of neatly acquiring the data they need from their unstructured data sources. In this example, we showed the slight differences between Standard and Floating Traps, and how they can both be potentially used to capture the same information in numerous ways. We also looked at the more advanced Regex Trap, which allows for a much higher level of customization, meaning users can pick out the exact pieces of text or numbers they need. Finally, we are left with the report shown in Figure 8. Naturally, we could go further, and continue to extract information, such as initial price, current value, number of pieces, etc., but the process would look largely like some combination of the steps taken in this blog.

Fig 8: Report output after creation of Regex Trap.

If you would like to learn more about the different types of traps in Altair Monarch, how to capture data more effectively in the tool, or just more about the software in general, please do not hesitate to reach out to us! Be sure to check back here often for more content like this, and subscribe to our YouTube channel for all sorts of video guides, software demonstrations, and case studies!


Share this post:

Top