I have some fields calculations and I want to create a pyqgis plugin using my expressions but I get Unexpected errors. For example if I do my task using field calculator in QGIS then it works, if i use the same expression in QGIS modeler it works again but does not work when using the same expression in pyqgis.
I dont know why because I use the same expression.
Here is the pyqgis code :
outputs_QGISFIELDCALCULATOR_6=processing.runalg('qgis:fieldcalculator', outputs_QGISFIELDCALCULATOR_5['OUTPUT_LAYER'],'mynewfield',1,10.0,0.0,True,'left( "field1", strpos( "field1" ,'_')-1)',None)
and I get syntax error.
that is from model export and in the model working nice.
Finally i try advanced python field calculator but that now work for me.