# Pattern Count

*Pattern Count* is the number of patterns that Astera matches on your file to capture a data region. This is useful if more than one pattern is required to identify the beginning of your data region. You can specify up to five patterns in a report model at a time.

In this document, we will explore how the *Pattern Count* feature helps with the selection of a data region.

## Loading an Unstructured File

1. Open a *Report Model* in Astera by going to *File > New > Report Model.*

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/xjqvsna0tb4e82v9Xpcg/image.png" alt=""><figcaption></figcaption></figure>

2. Provide the *File Path* for the unstructured file from your directory.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/Ace9WJWwN2fadsToJkBZ/image.png" alt=""><figcaption></figcaption></figure>

Astera supports extraction of unstructured data from Excel, csv, text, PRN, PDF, word, rtf and xls files. In this case, we are extracting data from a text file.

3. Click *Open*. A text file containing information regarding orders to a fictitious furniture store will open in the report model.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/HjBJMarGLh4cnQ6sQtC1/image.png" alt=""><figcaption></figcaption></figure>

Now that the file is open, we will create an extraction template.

## Creating a Report Model

1. Right-click on the *Record* node in Model layout under the *Report Browser* panel and select *Add Data Region* from the context menu.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/v5aQXuGSJfFhH5bBMJnt/image.png" alt=""><figcaption></figcaption></figure>

A pattern-matching bar and *Region Properties* panel will appear. And a subnode "Data" is added to the *Record* node in the Model Layout tab.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/Ddlxz9uELLH64gURiIgl/image.png" alt=""><figcaption></figcaption></figure>

2\. Specify the pattern that the report model can look for and match in your file to capture data. You can use an alphabet, character, number, word, a wild card or any combination of these to define your pattern.

Astera has built-in wild cards to facilitate region selection.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/vqXOjNXX9PQGIEMiWt4X/image.png" alt=""><figcaption></figcaption></figure>

<table data-header-hidden><thead><tr><th width="160"></th><th></th></tr></thead><tbody><tr><td><strong>Wild Cards</strong></td><td><strong>Description</strong></td></tr><tr><td><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/dWufp7gPF9yY0XAaqeRv/image%2020230817141841200.png" alt="image-20230817141841200"></td><td>It matches any alphabet on the file.</td></tr><tr><td><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/yAkfDoNcXJ4sNkVSjTsr/image%2020230817141916923.png" alt="image-20230817141916923"></td><td>It matches any digit on the file.</td></tr><tr><td><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/TGQro9QaihtVtXIl7esF/image%2020230817141956380.png" alt="image-20230817141956380"></td><td>It matches any alphabet or digit on the file.</td></tr><tr><td><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/PwGyiwpHFOqEuyZx24B9/image%2020230817142024140.png" alt="image-20230817142024140"></td><td>It matches any non-blank character on the file.</td></tr><tr><td><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/THclgOS6fMUhB5R4BLEM/image%2020230817142046770.png" alt="image-20230817142046770"></td><td>It matches any blank character such as line, space, tab etc. on the file.</td></tr></tbody></table>

In this example, we want to capture the data highlighted in yellow. Notice that each item has a specific item code, which we can use as a pattern to extract all the item details.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/GlF0kN6cRc0TpwwcxL4c/image.png" alt=""><figcaption></figcaption></figure>

3\. The pattern is a combination of three alphabets, a hyphen, and five digits. You can use the relevant wildcards to specify the pattern. In this case, notice that some item-codes are different from this pattern. The digits in the codes appear before the alphabets. As a result, RUGS has not been captured in the data region.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/GDMa6o1whhwgSsUwWjxM/image.png" alt=""><figcaption></figcaption></figure>

4\. In this scenario, to capture the region completely, we'll specify another pattern. You can specify up to five patterns in a single data region. We'll go to the Pattern Properties panel and increase the Pattern Count to 2. Another pattern bar appears.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/iwqrX7RreKCmo8bUsA4a/image.png" alt=""><figcaption></figcaption></figure>

5\. On the second pattern bar, we'll specify another pattern where the 5 digits come before the 3 alphabets, separated by a hyphen. Now, all the lines with item details have been captured completely in the data region.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/WGWoGv1zJ3lteO9Zg2cY/image.png" alt=""><figcaption></figcaption></figure>

6\. Once our data region is defined, the next step is to create data fields. To do that, you can highlight each field area, right-click and select *Add Data Field.*

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/JI8xCHO8b9lIjFT6ODns/image.png" alt=""><figcaption></figcaption></figure>

7\. Repeat the process to create more data fields and name them as shown below.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/vdOvfEq3xGmWcSMf1pdi/image.png" alt=""><figcaption></figcaption></figure>

8\. Preview data by clicking on the *Preview Data* icon placed in the toolbar at the top of the designer window.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/RvKg0LuFlII8O5LiVuHF/image.png" alt=""><figcaption></figcaption></figure>

9\. A window will open, asking you to save the file before proceeding. Save the report model at your required path.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/8x7ssyjFtJ2l2uCWEXfO/image.png" alt=""><figcaption></figcaption></figure>

10\. Once saved, a *Data Preview* window will open, displaying a preview of the extracted data.

<figure><img src="https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/0DxShXSFg96jFu4fFZIQ/image.png" alt=""><figcaption></figcaption></figure>

This concludes our discussion on working with an increased *Pattern Count* in Astera.
