[GIS] How to add new columns with attributes in existing Qgis layer

attribute-tablepythonqgis

How to add new columns with attributes in existing Qgis layer?
Doing the "same thing" here described

Best Answer

To add info to an existing layer instead of in memory layer you need to point to a layer on disk with QgsVectorLayer:

vl = QgsVectorLayer("C:\Temp\pt.shp", "pt", "ogr") 

Then you may continue to reference the code snippet from this Q/A:

How to create a new empty vector layer programmatically?