Add select_cell method
This commit is contained in:
parent
47837f073a
commit
b009a33bf3
|
@ -27,19 +27,21 @@ class ScrubLayer:
|
|||
self.layer = self.load_layer()
|
||||
self.data_count = self.layer.featureCount()
|
||||
|
||||
def cell_value(self, fid, field_name):
|
||||
def get_cell(self, fid, field_name):
|
||||
return self.layer.getFeature(fid)[field_name]
|
||||
|
||||
def cell_field_fields(
|
||||
def select_cell(
|
||||
self,
|
||||
field_name, field_name_value, field_field_value,
|
||||
field_name, field_value, required_field,
|
||||
return_one_value=False):
|
||||
expression = QgsExpression(f'{field_name} = {field_name_value}')
|
||||
"""Returns the value of a field
|
||||
based on the value of another field in the same record"""
|
||||
expression = QgsExpression(f'{field_name} = {field_value}')
|
||||
request = QgsFeatureRequest(expression)
|
||||
features = self.layer.getFeatures(request)
|
||||
field_field_values = []
|
||||
for feature in features:
|
||||
field_field_values.append(feature[field_field_value])
|
||||
field_field_values.append(feature[required_field])
|
||||
if return_one_value and field_field_values:
|
||||
return field_field_values[0]
|
||||
return field_field_values
|
||||
|
|
Loading…
Reference in New Issue
Block a user