diff --git a/scrub_layer_class.py b/scrub_layer_class.py index 06fa23c..5d39578 100644 --- a/scrub_layer_class.py +++ b/scrub_layer_class.py @@ -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)}')