Exporting and Importing Trifacta Wrangler Recipes

Tim Gray
December 8, 2015

We have been playing around with Trifacta a lot recently. As we know Trifacta = I can code (well, sort of). But as with any code we want to be able to save it, store it in Git and reuse it. Here is a short tutorial on how to get your script out of, and then back into, Trifacta Wrangler.


Exporting from Trifacta Wrangler is easy!
Pop open the script view from the right

ScriptOpen w Circle

Once this is open click the save button

ScriptSave w Circle

Then Wrangle Script and save in the desired location


Once done you should have a script a bit like this:

splitrows col: column1 on: 'rn'
keep row: matches([column1], `{alpha}+ {lower}+ {lower}+:`)
delete row: matches([column1], `Log file created:`)
extract col: column1 on: `[{upper}{4,6}]`
extract col: column1 on: `{lower}+-{lower}+-{digit}+` after: `{delim}`
rename col: column3 to: 'region'
rename col: column2 to: 'log_level'
extract col: column1 after: `{delim}`
rename col: column2 to: 'message'
extract col: column1 from: `(` to: `)`
rename col: column2 to: 'error_message'
drop col: column1


Importing a saved script into Trifacta Wrangler’s free version is a bit more tedious though no more difficult.
Create a Dataset, Select the Data and open the Transform view.


Now for every line in the script (except the first line in most cases) copy and paste into the Transform Expression box and click add to script.


Once this has been done for every line in the script we are ready to go!


What now?

Now that we know how to get a script out of Trifacta what can we do with it? The easy answer is put it somewhere safe, for example Git. My favorite thing to do is use this recipe somewhere else like Python to take more direct control of my data. We might hear more about that later. Until then have fun with your precious Trifacta scripts.
Coffee to Code – Tim Gray

Tim works on a lot of things here at optimal and writes blogs on a wide range of topics.

Connect with Tim on LinkedIn or read his other blogs here.

Copyright © 2019 OptimalBI LTD.