Created
April 20, 2023 20:07
-
-
Save antoniolocandro/724af574c68cebf8f38632ef310ef2e5 to your computer and use it in GitHub Desktop.
Test_Array_Replace
This file contains 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
layer = QgsProject.instance().mapLayersByName('replacement_table')[0] | |
test = QgsProject.instance().mapLayersByName('test')[0] | |
#print (layer.name()) | |
#print (test.name()) | |
feat = layer.getFeatures() | |
seat = test.getFeatures() | |
# create a dictionary for replacement | |
dict = {} | |
for f in feat: | |
dict[f.attributes()[0]]=f.attributes()[1] | |
#print (dict) | |
for s in seat: | |
b = s.attributes()[0] | |
c = b.split(',') | |
list = [] | |
for m in c: | |
d = m.replace('urn:uuid:','',1) | |
if d in dict: | |
list.append('urn:uuid:'+dict[d]) | |
else: | |
list.append('urn:uuid:'+d) | |
#c = b.replace(b,"urn:uuid",1) | |
#print (c) | |
g = ','.join(list) | |
print (g) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment