# Applying Pattern to Line

*Apply Pattern to Line* is useful when the specified pattern does not capture the first line of the desired data region or when there is some information above the pattern keyword. In that case, we increase the *Apply Pattern to Line* from 0.

In this document, we will explore how the *Apply Pattern to Line* feature helps select a data region.

## **Loading Unstructured File**

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

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F2rRrS4p3T3i0pJn0Quey%2F0.jpeg?alt=media)

2. A *Report Options* window will open.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fn7zW97zvJG5KX6JV3Dka%2F1.png?alt=media)

3. Provide the *File Path* for the unstructured file by clicking on the folder icon ![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FmfhZFN1thLw3lA1PFggc%2F2.png?alt=media)

Download the sample text file here.

{% file src="<https://content.gitbook.com/content/28dJIkGHacXhBlux3efx/blobs/min98zm33muzUbl8d6tf/16-Apply-pattern-to-line.zip>" %}

Astera supports unstructured data extraction from text, EDI, Excel, PRN, and PDF files. In this example, we are extracting data from a text file. Download the sample text file from here.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FHRi2c6StsEYY74eiSajs%2F3.png?alt=media)

There are many options available on the *Report Options* window to configure how you want Astera to read your file. The reading options depend on the file type. For example, if you have a PDF file, you can select the scaling factor, font, tab size, and passwords.

4. Click *OK*. A text file containing contact information will open in Report Model designer.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FgqNByQMsEr7UxzSqa2dc%2F4.png?alt=media)

Now that our file has been loaded to Astera, we will create an extraction template.

## **Creating a Report Model**

1. Right-click on the *Record* node in the Model layout under the Report Browser panel. Select *Add Data Region*.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FXiGgqmqzA8x1GpdOd6Ht%2F5.jpeg?alt=media)

A pattern box, Region Properties panel, and Pattern Properties panel appear above the Report Model designer.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FpArUSOAogLSio6FsR8gF%2F6.png?alt=media)

2. Specify a pattern that Astera can match on your file to capture data. In this example, we want to capture the data region highlighted in yellow.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FJDuNU0Cgm8iQjgaYhzlw%2F7.png?alt=media)

For this, write “Contact Information” in the pattern box to match it on the file as shown below.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FnEpxzeCbf061fvRHZ1AC%2F8.png?alt=media)

3. Notice that specifying a pattern alone is not enough to capture the entire data region in this example. Hence, we will increase its *Line Count* to 9.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fh5eGV99anKBUfRlo0CUJ%2F9.png?alt=media)

Observe that the data in lines above the data region (highlighted in grey) is still not captured.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fmw6tSeMZHaAhYxAxeOAB%2F10.png?alt=media)

4. To capture data in these lines, increase the *Apply Pattern to Line* to 1 as shown below.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F43fRPo5nh0AMkRytWpmE%2F11.png?alt=media)

5. Once our data region has been defined, the next step is to create fields. Highlight each field area, right-click, and select *Add Data Field.*

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FeOUZhSZSoIPLOZZ7NSuR%2F12.png?alt=media)

Repeat the process to create more data fields and name them as shown below. You can see the layout of the extraction template in the Model Layout panel.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F3y7Mm54Z9mmQ7TLTKx7Q%2F13.png?alt=media)

6. Preview data by clicking on the *Preview Data* icon ![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fx8ufWEaqprulmy6vhcdu%2F14.png?alt=media)placed in the toolbar at the top of the designer window.

A *Data Preview* window will open displaying a preview of the extracted data.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FOEv5vOhBWKH6R1ZWUdBC%2F15.png?alt=media)
