Expressions Basics

To flexibly extend Refine’s built in data exploration and transformation features, the system supports the use of Expressions in a variety of contexts. Unlike a spreadsheet formulas that are stored in a cell and update dynamically, Refine’s expressions are applied as an operation (like a scripting language) iterating over the rows of the data and outputting a result.

The most common use is when transforming the cells in a column or creating a new column:

  • Edit cells > Transform…
  • Edit column > Add column based on this column…

Less common uses:

  • Facet > Custom text facet… or Custom numeric facet…
  • Click “change” on a currently applied facet
  • Export > Templating…

Expression Editor

Refine’s interface provides an “Expression Editor” with features to help write and apply transformations to your data. This is a unique tool that makes Refine different than scripting languages or databases, giving you a visual interactive way to build up and test your expression while previewing the results.

openrefine interface window showing expression editor for custom text transform
  • Language
    • General Refine Expression Language (GREL) – a small set of functions specifically designed for data transformation puzzles in Refine. It is a good introduction to programming concepts because it is not large, you can learn it all and apply it in powerful ways!
    • Python / Jython – Python implemented on the Java VM. You can use python code and standard library, and send the result to the cell with return. Limitations: out of date Python 2 which was sunsetted in 2020.
    • Clojure – Lisp-family language implemented on Java VM. Limitations: not commonly used, little documentation.
  • Expression – text box a message to the right will say if there is a syntax error.
  • Preview – see live preview of expression, help testing and debugging expression, keep in mind it is only first 10 rows (your issue could be later in data). If the preview isn’t enough information, don’t hesitate to just run the operation and explore the results–you can always easily Undo/Redo!
  • History – operations you have recently used.
  • Starred – bookmark your operations! Save commonly used expressions that you can edit to quickly re-use.
  • Help – internal docs for quick reference while you are writing.
  • On error – this is important to understand implications! For many expressions any cell blank value will result in an error, leaving the resulting cell unexpectedly blank.