Delete feature by index method
This commit is contained in:
parent
e849ca568c
commit
ac3c44b965
@ -194,6 +194,16 @@ class ScrubLayer:
|
||||
# Update layer fields
|
||||
self.layer.updateFields()
|
||||
|
||||
def delete_record_by_index(self, record_index):
|
||||
self.layer.startEditing()
|
||||
|
||||
if self.layer.deleteFeature(record_index):
|
||||
print(f"Feature with ID {record_index} has been successfully removed.")
|
||||
else:
|
||||
print(f"Failed to remove feature with ID {record_index}.")
|
||||
|
||||
self.layer.commitChanges()
|
||||
|
||||
def conditional_delete_record(self, field_name, operator, condition):
|
||||
request = QgsFeatureRequest().setFilterExpression(
|
||||
f'{field_name} {operator} {str(condition)}')
|
||||
|
Loading…
Reference in New Issue
Block a user