Last active
May 19, 2016 07:53
-
-
Save PhillRob/5c8f4d31b852fe73647675a8cfbcbbae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m qgis.utils import iface | |
layer = iface.activeLayer() | |
layer.startEditing() | |
compare_field_index = 2 | |
concat_field_index = 9 | |
new_field_index = 14 | |
feature_dict = {f.id(): f for f in layer.getFeatures()} | |
for f in feature_dict.values(): | |
if f[concat_field_index]: | |
new_field_text = f[concat_field_index] | |
else: | |
new_field_text = '' | |
# Another for loop to go over features | |
for compare_f in feature_dict.values(): | |
if (f != compare_f | |
and | |
(f[compare_field_index] == compare_f[compare_field_index])): | |
print '%s matches' % f[compare_field_index] | |
if compare_f[concat_field_index]: | |
new_field_text += compare_f[concat_field_index] | |
print new_field_text | |
f[new_field_index] = new_field_text | |
layer.commitChanges() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment