I'm trying to iterate through all the features of a layer to change the value of some of its attributes. I'm using the following code:

from qgis.core import *
import os

working_folder = r'C:\myFolder'
fc_Opt_Prospect = os.path.join(working_folder, 'Equipm.gdb|layername=Prosp')

layer = QgsVectorLayer(fc_Opt_Prospect, 'Optimity_Prospect', 'ogr')


for f in layer.getFeatures():
    layer.changeAttributeValue(f.id(), 4, 3)
    layer.changeAttributeValue(f.id(), 5, 6)


When I check the attribute table of the layer I can see that no value has been changed. No error is thrown by the script.


QGIS can't edit Esri file geodatabases, even at version 3.8:

enter image description here


I have realised that "layer.startEditing()" is returning false. For some reason the layer is not editable. I guess that's the reason why values are not changed at all with the script above. Now remains the question of why the layer is not editable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.