Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antoniolocandro/724af574c68cebf8f38632ef310ef2e5 to your computer and use it in GitHub Desktop.
Save antoniolocandro/724af574c68cebf8f38632ef310ef2e5 to your computer and use it in GitHub Desktop.
Test_Array_Replace
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