In the data example below, each column in the fixed-width file is separated by a space. The data in the first column represents a 5-digit employee ID followed by 1 space for a total column length of 6. The data in the next column represents an 11 character first name followed by a space, for a total column length of 12. Each record ends with a hidden CRLF delimiter. When adding these columns to the RowSet variable 'myData,' the data will be trimmed of any trailing spaces.
Follow the steps below to read the first two columns from a fixed-width file.
From within the Project Designer page, expand the Data Translation folder in the Component Library, and then drag the Read Fixed-width task to the Project Outline.
On the Basic tab of the Read Fixed-width task, specify values for the following attributes:
Input File
The
file path and file name of a single file from which to read data.
Output RowSet Variable
The name of a variable which will contain the data read from the specified input file.
On the Advanced tab of the Read Fixed-width task, specify the Skip First Row value:
Skip First Row
Whether or not to skip the first row of the input file. If the input file contains header information in the first row, set this value to 'true'. In the example above, there is no header information, so the setting would be set to false.
Click the
Add
button to Specify Data Option for the Read Fixed-width task.
In the Data window, click the
Add
button and select the
Add Column
option.
On the Basic tab of the Column element, specify values for the following attributes:
Index
The index of the column in the input file. In the example above, the column used for the first Index is the Employee ID column, which is Index 1.
Name
Specify the name of the column.
Size
The size of the column. In the example above, the size is 6.
On the Type Conversion tab of the Column element, specify values for the following attributes:
Type
The default type is Variable Character (VARCHAR). Specify a different type if needed.
Pattern
The pattern to use to format
numeric or date/time fields.
On the Data Options of the Column element, specify a value for the trim attribute:
Click the
Add
button and choose Add Same to add another column.
On the Basic tab of the Column element, specify values for the following attributes:
Index
The index of the column in the input file. In the example above, the column used for the second Index is the First Name column, which is Index two (2).
Name
Specify the name of the column.
Size
The size of the column. In the example above, the size is twelve (12).
On the Type Conversion tab of the Column element, specify values for the following attributes:
Type
The default type is Variable Character (VARCHAR). Specify a different type if needed.
Pattern
The pattern to use to format
numeric or date/time fields.
On the Data Options of the Column element, specify a value for the trim attribute:
Repeat steps 10-13 for each column in the file. You can also specify a column name for each field, which can be referred to in later tasks by utilizing the Name attribute.