I have some data which is built like this:
a,bbb,ccc
where bbb and ccc vary in length.
I want to extract the last segment of the string, after the second ",". Using the Function Editor:
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def sp_split(value1):
return value1.split(",")[2]
I save it as a function called sp_split
, but when I call it in the expression with a field for a value, it doesn't recognize it.
Pressing More Info gives me this explanation:
Eval Error:
sp_split() takes exactly 1 argument (3 given)
What might be the reason for that? I'm at a loss here. I'm using the function because of the split, if there is another way of using the built-in expression to retain the "ccc" part, I'll gladly use it.
sp_split(value1, feature, parent)