Google Refine Expression Language (GREL) is to OpenRefine what formulas are to Excel or SQL to a database: a way to accomplish more complex transformations, queries, and arrangement of data. In OpenRefine, GREL can be used in four places:
All GREL input windows in OpenRefine share a similar layout:
In this case, the values of the current column will be searched for the string ‘cat’ which will be replaced by the string ‘dog’.
GREL includes a specific vocabulary for referring to cell values:
value= the values in the current column
cells['Column2'].value= the values in the specified column, ‘Column2’
A string can be written with either single or double quotation marks.
Below is a list of commonly used expressions for quick reference. For more detailed information on GREL, please see About Regular Expressions.
|Google Refine Expression Language||Function|
||replaces 'string1' with 'string2' in the current column|
||replaces blank spaces with no space|
||replaces quotations with blank space (NOTE: double quotations must be used on the outside.)|
||concatenates the values in the specified columns|
||adds 'string' to the values in the specified column|
||concatenates the values in the current column with the values in the specified column with a space in between|
||returns the first element of a string based on the character type|
||compares two columns against one another|
||checks to see if values in a column contain 'string'|
||checks to see if values in a column start with 'string'|
||checks to see if values in a column end with 'string'|
||returns the difference between 'date 1' and 'date 2' in the format (months, days, etc.) specified|
NOTE: GREL is case sensitive, so be sure to check column names, strings, etc. are accurate before applying an expression.
5/21/2018 - Brinna Michael