Page tree



Contents:

NOTE:  Trifacta Wrangler is a free product with limitations on its features. Some features in the documentation do not apply to this product edition. See Product Limitations.

   

This example demonstrates how to convert an input string to a base64-encoded value and back to ASCII text strings.

Functions:

ItemDescription
BASE64ENCODE Function Converts an input value to base64 encoding with optional padding with an equals sign (=). Input can be of any type. Output type is String.
BASE64DECODE Function Converts an input base64 value to text. Output type is String.

Source:

The following example contains three columns of different data types:

IntegerFieldStringFieldssn
-2082863942This is a test string.987654321
2012994989"Hello, world."987654322
-1637187918"Hello, world. Hello, world. Hello, world."987654323
-1144194035fyi987654324
-971872543
987654325
353977583This is a test string.987-65-4321
-366583667"Hello, world."987-65-4322
-573117553"Hello, world. Hello, world. Hello, world."987-65-4323
2051041970fyi987-65-4324
522691086
987-65-4325

Transformation - encode: 

You can use the following transformation to encode all of the columns in your dataset:

Transformation Name Edit column with formula
Parameter: Columns All
Parameter: Formula base64encode($col, true)

Results - encode:

The transformed dataset now looks like the following. Note the padding (equals signs) at the end of some of the values. Padding is added by default.

IntegerFieldStringFieldssn
LTIwODI4NjM5NDI=VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==OTg3NjU0MzIx
MjAxMjk5NDk4OQ==IkhlbGxvLCB3b3JsZC4iOTg3NjU0MzIy
LTE2MzcxODc5MTg=IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==OTg3NjU0MzIz
LTExNDQxOTQwMzU=ZnlpOTg3NjU0MzI0
LTk3MTg3MjU0Mw==
OTg3NjU0MzI1
MzUzOTc3NTgzVGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==OTg3LTY1LTQzMjE=
LTM2NjU4MzY2Nw==IkhlbGxvLCB3b3JsZC4iOTg3LTY1LTQzMjI=
LTU3MzExNzU1Mw==IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==OTg3LTY1LTQzMjM=
MjA1MTA0MTk3MA==ZnlpOTg3LTY1LTQzMjQ=
NTIyNjkxMDg2
OTg3LTY1LTQzMjU=

Transformation - decode:

The following transformation can be used to decode all of the columns:

Transformation Name Edit column with formula
Parameter: Columns All
Parameter: Formula base64decode($col)

Results - decode:

IntegerFieldStringFieldssn
-2082863942This is a test string.987654321
2012994989"Hello, world."987654322
-1637187918"Hello, world. Hello, world. Hello, world."987654323
-1144194035fyi987654324
-971872543
987654325
353977583This is a test string.987-65-4321
-366583667"Hello, world."987-65-4322
-573117553"Hello, world. Hello, world. Hello, world."987-65-4323
2051041970fyi987-65-4324
522691086
987-65-4325

See Also for EXAMPLE - Base64 Encoding Functions:

This page has no comments.