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:

TRIM
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
trim(MyName)

trim(MyName)

Output:

...

Returns the values of the MyName column value with whitespace removed from the beginning and the end. 

String literal example:

TRIM
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
trim(' Hello, World ')

trim(' Hello, World ')


Output:
The string  Returns the string:Hello, World is written to the new column.

D s
snippetSyntax

TRIM
d-codelang-syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:
trim(column_string)

trim(column_string)


ArgumentRequired?Data TypeDescription
column_stringYstringName of the column or string literal to be applied to the function

...

mystring
Here's my string.
(space)(space)Here's my string.(space)(space)
"(tab)Here's my string.(tab)"
"(cr)Here's my string.(cr)"
"(nl)Here's my string.(nl)"
"(space)(space)(tab)Here's my string.(tab)(space)(space)"
"(space)(space)(tab)(cr)Here's my string.(cr)(tab)(space)(space)"
"(space)(space)(tab)(nl)(cr)Here's my string.(cr)(nl)(tab)(space)(space)"

TransformTransformation:

You might notice the quote marks around most of the imported values. 

...

The first step is to remove the quote marks. You can select one of the quote marks in the data grid and then select the appropriate Replace suggestion card. The transform should look like the following:

d-

...

trans
RawWrangletrue
p03Value''
Typestep
WrangleTextreplace col: mystring on: `"` with: '' global: true
p01NameColumn
p01Valuemystring
p02NameFind
p02Value`"`
p03NameReplace with
p04Valuetrue
p04NameMatch all occurrences
SearchTermReplace text or pattern

Now, you can apply the TRIM trim function:

d-

...

trans
RawWrangletrue
p03Value'trim_mystring'
Typestep
WrangleTextderive type:single value:

...

trim(mystring) as: 'trim_mystring'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuetrim(mystring)
p03NameNew column name
SearchTermNew formula

Results:

In the generated trim_mystring column, you can see the cleaned strings:

...