I am trying to populate an attribute table of a feature with attributes from another feature. I have been able to segregate the input data into fields named "From", "Eastings" and "Northings". I find this is not such a difficult task to carry out as this code helped. The problem now is the input data has only four(4) rows but when I run my script, it multiplies the number of rows and I end up with twenty rows. I am quite sure I need to change something in the code, i am not sure where as I am relatively new to python.
here is my code:
pr.addAttributes([QgsField('FROM', QVariant.String)]) vpr.addAttributes([QgsField('Eastings', QVariant.Double)]) vpr.addAttributes([QgsField('Northings',QVariant.Double)]) vlayer.updateFields() vlayer.startEditing() for things in vlayer.getFeatures(): for i in new_attribs: things['FROM'] = i things['Eastings'] = i things['Northings']=i things.setAttributes(i) vpr.addFeatures([things]) vlayer.updateFeature(things) vlayer.commitChanges()
This is the result I get:
How do I get only the four(4) rows I need?