Let's imagine to have a vector layer whose attribute table is made of an ID field, a field "A" (string) and a field "B" (float).
I am trying to access a specific feature (e.g. ) in field A, comparing the selected value with the one after() in the same column and, based on this, doing something.
If I were working on a spreadsheet, I'd write: IF(A0=A1; B0=x;""). Based on the final hint enclosed in a previous discussion (link), which is quite closed, I tried to use it but:
it moves among fields (horizontally) and not features (vertically)
and I should activate it for each feature (but what about if there are many features?)
features = layer.getFeatures() attrs = feat.attributes() attr = attrs Index=2 # field index request = QgsFeatureRequest().setFilterFid(0) #feature index feat = layer.getFeatures(request).next() print feat.attributes()[Index] #thus, the result returned is the first feature in third field Index=Index+1 #I change the index to the 1st.one on the right print feat.attributes()[Index] #thus, I obtain the 1st feature of the 4th field