In QGIS I want to search for a specific case and if this is true then replace the text in multiple columns. Based on Use updatcursor to replace values in multiple fields, Update multiple fields/columns in QGIS and Elseif Conditional Statement in QGIS Field Calculator
I have
# definition of the function which calculates new values
def upd_value(sfield, svalue, outvalue):
# criteria
if search<>svalue:
outvalue=svalue
return outvalue
# get the active layer
layer = iface.activeLayer()
prov = layer.dataProvider()
# get the fields
fnm = prov.fieldNameMap()
# get an iterator for the features
feats = prov.getFeatures()
# calculate new values and update fields with fieldnames
I am not sure how to end this. Basically I need the following
When
lower("Given_name")<>lower( "z_Given Names") and 'Surname' is not Null
Then
"Given_Name" field should be filled with "z_Given_Names"
"Surname" field should be filled with "z_Surname"
(lots of other fields which I can add in once I know what to do)
"Status" with 'Updated fields from z table as names not same'
When
"Status" = 'V' and "Surname" is Null
Then
"Given_Name" field should be filled with "z_Given_Names"
"Surname" field should be filled with "z_Surname"
"Status" with 'New'