Skip to content

Instantly share code, notes, and snippets.

@mcampos-quinn
Last active May 12, 2020 00:07
Show Gist options
  • Save mcampos-quinn/94b3b10796110043a45b2163156e7d81 to your computer and use it in GitHub Desktop.
Save mcampos-quinn/94b3b10796110043a45b2163156e7d81 to your computer and use it in GitHub Desktop.
recipes and stuff for openrefine, grel expressions
################
Transform cells containing a single name in `Fn Mn Ln` format into `Ln, Fn Mn`
value.split(/ (?=[^ ]*$)/).reverse().join(", ")
the split regex catches the last " " space that occurs and takes the characters after it as the last name,
then moves it to the front and joins the values with comma-space.
To perform this transformation, at the top of a column, go to Edit Cells> Transform and paste the expression into the box.
####################
####################
JYTHON
Transform cells from pipe-delimited to python-list-like
Jane Doe|John Doe --> ["Jane Doe","John Doe"]
value = value.encode('latin-1')
x = '["{}"]'.format(value.replace("|",'","'))
return x
####################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment