When I use "Update existing fields" in the Field Calculator in QGIS 3.16.0-Hannover, it takes only a second to change all the values in a attribute field to the same value. However when I try to do that with PyQGIS, QGIS crashes.
I have a layer with line geometry with 82800 features inside. I want to change all feature's value inside "visited"
column to '0'. Here is how I try to do that:
layer = iface.activeLayer()
lines = [feat for feat in layer.getFeatures()]
layer.startEditing()
for line in lines:
line["visited"] = 0
layer.updateFeature(line)
layer.commitChanges()
Can I do that like I do that with field calculator via using PyQGIS (with expressions or something)?