Reputation: 11
I don't know how to split these lines with Open Refine:
ABGB: Praxiskommentar Schwimann/?Kodek AHG Amtshaftungsgesetz: Praxiskommentar Ziehensack
--> so I have the values like this:
Title | Author |
---|---|
ABGB: Praxiskommentar | Schwimann/?Kodek |
AHG Amtshaftungsgesetz: Praxiskommentar | Ziehensack |
I already tried it with the grel expression value.split(' ')[-1] but with this I'm only getting the author names. Can anybody help me with this? Thank you
Upvotes: 1
Views: 59
Reputation: 651
I guess you are already on the right track.
So you first add a new column Author with the GREL expression value.split(' ')[-1]
.
You then have to remove the author from the Title column using the transform dialog.
Solution using GREL arrays:
For this solution we are again splitting the value
using whitespace.
The tricky part is then to remove the last element from the array.
For this we have to bind the array to a variable a
using with. After that we can calculate the length of the array and reduce it by one. This enables us to get only the title elements from the array. We then use join to write the remaining array values back as string.
with(value.split(' '), a, a.get(0, a.length()-1)).join(' ')
Solution using replace:
A more intuitive solution is to directly replace the value from the colum Author in the column Title. This solution is more prone to errors as it will also replace the name of the author if it is part of the title.
value.replace(row.cells["Author"].value, "").trim()
Upvotes: 1