I am writing a script that converts dxf drawing to a shapefile. Using my script now I can create a shapefile. Attribute table of that shapefile is initially empty and it has only one row. In that attribute table, there is a column called "Req_No". I make Req_No column value in to 23 and try the following code and it works.
selection=vl.getFeatures(QgsFeatureRequest().setFilterExpression(' "Req_No"=23')) for feat in selection: vl.changeAttributeValue(feat.id(),1, '45') vl.changeAttributeValue(feat.id(),2, 'H.M.P.jagath') vl.commitChanges()
Now I want to do this automatically. If I further explain, I want attribute table to update while the shapefile is forming. But initially attribute table columns are all empty.
How should I change the above mentioned code when Req_No column is Null?
I am using QGIS version 2.18.9.