# Fixed Length Parser

*Fixed Length Parser* processes a stream of fixed length data as an input and gives 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.

**Sample Use-Case**

The sample data that we are using is a Fixed-Length text file containing customers’ information.

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

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.

**Extracting Data**

To parse the data, we first have to extract it.

Since the data is stored in a continuous stream, it can not be extracted 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 parsing the data.

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

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FzFvblBPPLCAuJyPHIL7S%2F2.gif?alt=media)

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

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

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

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

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

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

You can 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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FoJFxlERf37lL7reR4juw%2F6.gif?alt=media)

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FHb1PZkHySN5ircLBQfiI%2F7.gif?alt=media)

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FI3RbpJRWw0dzcKxH2iR9%2F8.png?alt=media)

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

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

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

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

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

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

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fp9XGxvLw6j1tiCUnFAci%2F12.png?alt=media)

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

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

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

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

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://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FGwlVt4stlImkYLbvszEy%2F15.gif?alt=media)

2. Configure settings for the [*Excel Workbook Destination*](https://documentation.astera.com/astera-data-stack-v9/dataflows/sources/excel-workbook-source) object.
3. Click on the *Start Dataflow* icon, located in the toolbar at the top, to create this destination file.

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