# Fixed Length Parser

*Fixed Length Parser* processes a stream of fixed length data as an input and give elements as parsed output. This is useful when the source data is in text format (information is contained in a single field) and it needs to be put into multiple fields for further integration.

In this document, we will learn how you can use *Fixed Length Parser* in Astera.

### Sample Use-Case

The sample data that we are using is a fixed length text file containing customers’ information.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FSJ7uSbKHkBoIBTNRaS0D%2F1_data.PNG?alt=media\&token=2b014813-91bf-4023-aad2-3a0a7407df94)

Observe that all the information such as name, street number, street type, city, state, and zip code are concatenated in a single field. We want to parse the *Contact\_Details* field into *Name*, *Street Number*, *Street Type*, and other respective fields.

To parse the data into separate fields, we will use the *Fixed Length Parser* object in Astera.

#### Extracting Data

To parse the data, we first have to extract it. Since the data is stored in a continuous stream, can not extract it directly using a *Fixed Length File Source* object. Therefore, we will use a combination of transformations to get the desired outcome. The diagram below explains the process that we’ll be following, right from extraction to to parsing the data.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F3vomxLpUXWRwfDUe96Pu%2Ftemplate.PNG?alt=media\&token=ca658d7b-8d3e-4967-b101-d395d164ccd6)

Let’s begin with extracting the data.

1. Go to *Toolbox > Transformations > Constant Value* and drag-and-drop the *Constant Value* object onto the designer.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FzqGFnaNmDyJ7Nv6WEp0H%2Fcontant_value.gif?alt=media\&token=c6c19e29-a7fe-4b58-8a65-95a36521587e)

2. Right-click on the object’s header and select *Properties* from the context-menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FjgeZBY32wx39jNj6YL1U%2F3_properties.png?alt=media\&token=fff89584-df84-4d1f-8c62-6df8e61b8804)

3. In the *Constant Value* field, provide the file path of the source file (file containing customers data in a stream). Click *OK*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FTn7fkCjGrNX4An6jJHZW%2F4_filepath.png?alt=media\&token=e1b98169-8ca4-4970-aa80-4913e6b5d1ef)

4. Next, go to *Toolbox > Function Transformations > Files > ReadFileText(String filePath) - String*, and drag-and-drop the object onto the designer.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fswmjsvm8KDltpXSrTXND%2Fread_file_text.gif?alt=media\&token=fb261a86-e651-42cf-b83f-fce50f6e2473)

You an see that the dragged transformation object has two sub-nodes - *Input* and *Output.*

5. Expand the *Input* node and map the *Value* field from the *Constant Value Transformation* object to the *filePath* field inside the *Read File Text* object.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FiivraAgUrnRyfXJ08eRQ%2FMapping_CV.gif?alt=media\&token=deb109ff-3d56-4b31-89e5-2086c198b9d8)

This will redirect Astera to read the data from the given file path. Now we can use the *Fixed Length Parser* object to parse the text data into separate fields.

#### Using Fixed Length Parser

1. To get the *Fixed Length Parser* object, go to *Toolbox > Text Processors > Fixed Length Parser* and drag-and-drop the object onto the designer. Map the *Value* field, under the *Read File Text* object, onto the *Text* field inside the *Fixed Length Parser* object.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FD1zUxkzj6f463uNEtDMK%2FFLP_OBJECT.gif?alt=media\&token=f761e605-bb28-4ee3-93de-c07cfdc68cd3)

You can see that the dragged-object also contains an *Output* sub-node which is currently empty.

2. Configure the *Fixed Length Parser* object by right-clicking on its header and selecting *Properties*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FLZqIloRvNfbPZg5FFh28%2F11_properties.png?alt=media\&token=4cdd9556-2b35-4474-8ec5-4c7ecf93b687)

3. A properties window will open. Here you will see three options, make sure the first two options are checked.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FfqGxEnQ7E8OzSLgf0zz3%2F12_config.png?alt=media\&token=33ef0962-cd78-4552-a0db-dd37c2295426)

4. Click *Next*, and you will be directed to a *Source Fields* window.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F6BD3LwjAMgqIIJeKq4jS%2F13_field_window.PNG?alt=media\&token=a2dcc25a-899d-4fb5-afb1-632ae24c5dac)

Here, you have to provide the name of each field that you want to parse the source date into, as shown below.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F3S3ShZDpvRKLsgIXw0BQ%2F14_fields.PNG?alt=media\&token=027f1383-4c6a-4471-801f-de915971e0df)

5. Click *OK*. Now, expand the *Output* node inside the *Fixed Length Parser* object. You will see all the fields that you have created in the previous step.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FYEVZItIAa01GagHV4cdQ%2F15_output.PNG?alt=media\&token=dd62aa17-81fa-44e4-b726-ab1402a3b2ae)

6. Right-click on the object’s header and select *Preview Output* from the context menu.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F3srpL52WNnYxZxLx5HXG%2F16_preview_output.png?alt=media\&token=2ced878d-8329-4b4b-9355-bdead65fa760)

A *Data Preview* window will open. Expand the nodes, and you will see a parsed output of each record.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FYof0WF96HKQZNQPijFKE%2F17_data.PNG?alt=media\&token=764cfadd-1a46-424d-af50-52089a22f3ad)

To store this parsed output, write it to a destination file.

#### Writing to a Destination

1. Right-click on the *Output* sub-node inside the *Fixed Length Parser* object, and go to *Write to > Excel Workbook Destination*. An *Excel Workbook Destination* object will be added to the dataflow designer with auto-mapped fields.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fl6xSOZqlAFwCRCjKZPXa%2FFLP_destination.gif?alt=media\&token=de348158-1f53-41cd-a508-e7851b937e51)

2. Configure settings for the *Excel Workbook Destination* object.

Learn how to configure settings for *Excel Workbook Destination* from [here](https://documentation.astera.com/astera-data-stack-v10/dataflows/destinations/excel-workbook-destination).

3. Click on the *Start Dataflow* icon, located in the toolbar at the top, to create this destination file.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FpmRzt0Y08UI1kVYYU2vb%2F20_start_dataflow.png?alt=media\&token=afedf8f4-d349-4442-a628-2adb7044eb40)
