In partnership with the OKFN School of Data , we recorded last November an hour Skillshare on Refine GREL Language. Always wonder how to get started with the Generic Refine Expression Language (GREL)?
Watch this one hour tutorial and learn the basic of the language along with simple expression. Further tutorial will be published to go through each functions presented in this video.
Transformations are to Refine what formulas are to Excel, except rather than being stored in a cell, they are applied once to the entire dataset. GREL (for General Refine Expression Language) is the main language supported and let you write powerful yet simple query to filter and transform your data. You will use transformation function when the action available through Refine menu are not enough to do want you want.
You can access GREL from four different menu. When
- Creating a custom text facet
- Transforming a column using the transformation function
- Using add column based on this column
- Creating a new a column by fetching URL
In any GREL windows you will find the same five functions:
- At the top the Expression windows and the controller where you write your expression and check if the expression is well formatted.
- The preview tab show you a preview of your data before and after the transformation
- The history tab list of all the previous expression used in this project or other project so you can reuse them quickly.
- The starred tab to build your personalized bookmark of GREL expression
- The help tab list all the function available and their syntax. You can read more about each expression on the OpenRefine wiki.
When your expression generate an error Refine let you choose how to handle it. We recommend to keep the default behavior: keep original.
GREL Basic functions
Call content from current column: value
Call content from another column: cells[‘column_name’].value
to input text directly place it between single or double quote like "hello world"
GREL support two type of syntax inside out like Excel or in sequence. Even if most of you are familiar with the first method, we recommenand (and will use) the second expression as it is easier to read with writting complex expression:
- Inside out like Excel where you name your function first and then all you argument for example to turn the content to lowercase and then trim it you will write: trim(toLowercase(value))
- In sequence where you name first the target of the function followed by all the function separated by a dot. When the function have no other argument you just open and close the bracket. For example: value.toLowercase().trim()