K3 Documents

Fixed Width

Updated on

Fixed Width is a file format where data is arranged in columns, but instead of those columns being delimited by a certain character, such as  a comma in a CSV, every row is the exact same length.

The K3 Fixed Width source adaptor supports parsing data from a fixed width file format. The following instructions will walk through the steps to set up a Fixed Width adaptor.

1. Select the appropriate Fixed Width adaptor

K3 supports both FTP/SFTP polling or manual uploading of Fixed Width files. If the source file will be polled through FTP/SFTP, a URL, username, and password must be provided. All steps after providing credentials are the same between manual upload and FTP/SFTP polling.

FTP/SFTP Fixed Width

1. Select "Fixed Width" as the source adaptor to upload through FTP/SFTP

2. Click Input URL

Add the URL and credentials necessary to receive the file, then click Test Connection. If the URL and credentials are correct, the window will display the directories at located at the provided URL. 

To enter a different URL or correct the credentials, click Edit Parameters.

3. Add custom parameters

To add custom parameters to the FTP request, click Show Advanced Configuration on the bottom left of the Input URL screen. This will display several predetermined parameters that may be edited, followed by Add Custom Param.

Clicking Add Custom Param will add two blank fields to the end of the parameter list. Enter the name of the parameter on the left hand blank, and the value of the parameter on the right.


Advanced Parameter Description
delay time (in milliseconds) the adaptor will wait before executing the next poll
move

location where processed documents are moved to.

The default value (processed/${date:now:yyyyMMdd}/${file:name}) will place the processed documents in a folder based on the date and time the document was processed.


moveFailed location failed files are placed. The default value is "errors".
readLock

    prevents the FTP poll from consuming files that are currently being written. The default value, "changed", will only poll documents that have been modified since the last poll.


For advanced users, please see the camel file2 documentation for other options.

maxMessagesPerPoll maximum number of files the FTP will consume in a single poll. The default value is 20.
maximumReconnecteAttempts Each FTP poll can be customized further. For advanced users, please see the camel file2 and FTP component documentation.

Fixed Width Upload

1. Select "Fixed Width Upload" as the source adaptor to manually upload a fixed width document

2. Parse the file

Once the appropriate Fixed Width source adaptor has been selected, the user will be taken to the route configuration page where the fields need to be entered. Start by clicking the blue +Add button. This will add a row to enter the name of the field, the type of field, the offset of the field, and the length of the field. To add the next field, The blue +Add button will be located under the new Name field. 

Field Description
Name Name of the field
Type The data type of the field
Offset The initial cursor position of the field.
Length The number of characters that belong to that particular field.

In the below example, the first field of the file is System. Since its the first field, its offset it 0 because the cursor starts before the first character. The length is 1 character, which means that only one character is parsed into the System field. 

The offset of each subsequent field  will be the number of characters from the beginning of the file through the character immediately before the desired field begins. Since the offest is zero based, if a field begins at the 16th character of the file, the offset will be 15. 

Please note, K3 will not alert the user to any overlap, (i.e. the offset of one field is entered incorrectly and picks up the last character of the previous field). It will parse the file exactly as its directed to in the configuration. If any fields overlap, K3 will still pull the information it finds at the given locations and put it into the source table. If an error is discovered, correct the offset and length in the configuration.

Once all the fields have been entered, click Save Config to create the route.

Previous Article Oracle Source Adaptor
Next Article How to Run an Exchange Route with a Single Thread