Search code examples
replaceopenrefine

Searching and replacing multiple values in Google Refine


I'd like to search and replace multiple values in a column with a single function with GREL (or anything other) in Google Refine.

For example:
1. replace(value, "Buch", "bibo:Book")
2. replace(value, "Zeitschrift", "bibo:Journal")
3. replace(value, "Patent", "bibo:Patent")
4. and many more.

Is there a way to do this with one GREL expression?


Solution

  • For your first three, you can do:

    value.replace("Buch", "bibo:Book").replace("Zeitschrift", "bibo:Journal").replace("Patent", "bibo:Patent")
    

    Depending how many your "many more" is, that pattern may suffice. Otherwise you could investigate some type of table lookup (which might be easier in Python than GREL - just choose Jython for your expression language).