Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

Column reference example:

PAD
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextset col: Whse_Nbr value:
pad(Whse_Nbr, 6, '0', left)

...

pad(Whse_Nbr

...

, 6, '0', left)

Output: Returns a value of a minimum of six characters in length. For

...

input values that are shorter, the character 0 is added to the left side of the string.

String literal example:

PAD
d-code-lang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
pad('My Name', 10, '!', right)

pad('My Name', 10, '!', right)

Output: The string : Returns the string: My Name!!!! is written to the new column.

D s
snippetSyntax

PAD
d-code-lang-syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:
pad(string_val,string_length,pad_string,pad_side)

pad(string_val,string_length,pad_string,pad_side)

...

When the pad string contains multiple characters, the behaviors are different depending on the side on which the string is padded:

PAD
FunctionOutput Value
Code Block
D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextpad('12', 4, 'abc' left)

pad('12',

4,

'abc'

left)

Code Block
bc12
PAD
Code Block
D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextpad('12', 4, 'abc' right)

pad('12',

4,

'abc'

right)

Code Block
12ab
Code Block
PAD
D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextpad('12', 6, 'abc' left)

pad('12',

6,

'abc'

left)

Code Block
cabc12
Code Block
PAD
D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextpad('12', 6, 'abc' right)

pad('12',

6,

'abc'

right)

Code Block
12abca


D s
snippetusage

...

prodIdprodName
1Our First Product
2Our Second Product
3Our First Product v2
1001

A New Product Line

1002A New Product Line v2

TransformTransformation:

The first step is to convert the product identifiers to string values:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextsettype col: prodId type: 'String'
p01NameColumns
p01ValueprodId
p02NameNew type
p02Value'String'
SearchTermChange column data type

Then, you can apply the character 0 as padding to the left of these strings, so that all values are four characters in length at a minimum:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextset col:prodId value:

...

pad(prodId,4,'0',left)
p01NameColumns
p01ValueProdId
p02NameFormula
p02Valuepad(prodId,4,'0',left)
SearchTermEdit column with formula

Results:

prodIdprodName
0001Our First Product
0002Our Second Product
0003Our First Product v2
1001

A New Product Line

1002A New Product Line v2

...