The Pad template appears in the template list when a variable length text field, of type nvarchar or varchar, has been picked in the Transform pane. It appends or prepends the specified text string, repeating as desired, to the end or to the beginning of the target string.
Pad |
Pad text from the source field to the specified length by adding at the beginning or the end repeated text from another field, a value or an expression. The Repeat text is often a single character.
Launch the template by choosing a text field and then double-clicking the Pad template. When the template launches we can specify options.
|
Pad : end |
Append the specified padding string to the end of the source text to the specified length, as necessary truncating or padding at the end with the specified padding string, and save to the Result destination.
We start with a table that has a varchar text field called Country, which contains the names of various countries. We have used the Layers pane to hide the mfd_id field, for a simpler illustration.
With the focus on the table, in the Transform pane, the Country field is chosen by default (since it is the only field - we could have chosen it if there were other fields). We double-click the Pad template to launch it.
In the Pad template we choose end as the Pad option. For the Repeat text, we enter the single . character, and for Length we enter 20.
For the Result destination, we choose New Field, and we enter Padded country as the name of the new field. We choose the default nvarchar text data type offered for the new field.
Press Transform.
The template automatically creates a new nvarchar field called Padded country and populates it with text from the Country field, with additional . characters added to the end of each string.
All of the resulting Padded country strings are 20 characters in length with . characters added at the end to pad the lengths of strings from Country that were less than 20 characters.
Multiple characters can be used in the padding string.
We can run the transform again, this time choosing for the Repeat text, the two character -_ sequence (a hyphen followed by an underscore).
For the Result destination, we choose the Padded country field that was created in the table in the prior run.
Press Transform.
The result now uses repeated -_ two character sequences to pad each Padded country result out to a total length of 20 characters.
The Pad template will also shorten the resulting text if the specified Length is shorter than the source text strings.
We can run the transform again, this time choosing 3 for the Length.
For the Result destination, we again use the Padded country field that was created in the table in a prior run.
Press Transform.
When the source string is longer than the specified Length it will be truncated and the padding string ignored.
|
Pad : start |
Prepend the specified padding string to the end of the source text to the specified length, as necessary truncating or padding at the beginning with the specified padding string, and save to the Result destination.
We start with a table that has a varchar text field called Country, which contains the names of various countries. We have used the Layers pane to hide the mfd_id field, for a simpler illustration.
With the focus on the table, in the Transform pane, the Country field is chosen by default (since it is the only field - we could have chosen it if there were other fields). We double-click the Pad template to launch it.
In the Pad template we choose start as the Pad option. For the Repeat text, we enter the single . character, and for Length we enter 20.
For the Result destination, we choose New Field, and we enter Padded country as the name of the new field. We choose the default nvarchar text data type offered for the new field.
Press Transform.
The template automatically creates a new nvarchar field called Padded country and populates it with text from the Country field, with additional . characters added to the beginning of each string.
All of the resulting Padded country strings are 20 characters in length with . characters added at the start to pad the lengths of strings from Country that were less than 20 characters.
Multiple characters can be used in the padding string.
We can run the transform again, this time choosing for the Repeat text, the two character -_ sequence (a hyphen followed by an underscore).
For the Result destination, we choose the Padded country field that was created in the table in the prior run.
Press Transform.
The result now uses repeated -_ two character sequences to pad each Padded country result at the start to create a total length of 20 characters.
The Pad template will also shorten the resulting text if the specified Length is shorter than the source text strings.
We can run the transform again, this time choosing 3 for the Length.
For the Result destination, we again use the Padded country field that was created in the table in the prior run.
Press Transform.
The result is the first three characters from each of the source strings. Padding characters are ignored if the source string is less than or equal to the specified Length.
|