I have been trying to access the values of the attributes of certain features in a vector layer. I have tried to to as they suggest in How to read the attribute values using PyQGIS? and Getting feature attribute description with pyqgis?, but whenever i try to define the feature with next(), i get StopIteration exception. This stops my program as if it was an error. I have been working on it for quite some time, but I haven't been able to find a way around it.
Is there a way to get attribute values from specific features of the vector layer without getting stoped by "StopIteration"?
I am working in QGIS 2.18
EDIT, Code snippit:
for i in range(0, len(vaiable)):
request = QgsFeatureRequest().setFilterFid(i)
iterator = layer.getFeatures(QgsFeatureRequest().setFilterFid(i))
feature = next(iterator)
#feature = layer.getFeatures(request).next()
I have tried with both iterator and request, with but StopIterator is raised when trying to assign "feature" in both cases