ifbreakVar==1:# passing on of the break from the inner loop
break;
ifsource=="":
continue# then there is an empty source: although an incorrect entry in the data set, it causes a lot of damage
# it is not enough to just look if source is in source2, it must be the same
forn5,source2inenumerate(sources2):
ifsource==source2andy["id"]!=idRelativeandy[
"Rolle"]=="Erblasser"andpartOfNameIsEqual==1:# i["lastname"] in y["lastname"]: # 2. Bed: Soll nicht gleich die ursprüngliche Person sein, 4. Bed: nachnamen gleich sein, weil eine Person zwei Drittpersonen haben kann; name der Drittperson oft weniger umfangreich
idList.append([i["id"],y["id"]])
noDouble=1
breakVar=1
break# continue to next person
ifnoDouble==0andn3==len(
data)-1:# if the last one has not been found yet, then it is only one person
idList.append([i["id"]])
# also print if there is no third person, otherwise only the third persons appear
else:
idList.append([i["id"]])
# some IDs to be merged are present at this place at the same time again individually
# leads to the double output of persons
# there is to underprint, the single persons must be removed
# generate a list with the persons to be merged
idListMergedPerson=[]
foriinidList:
iflen(i)!=1:
foridMergedPersonini:
idListMergedPerson.append(idMergedPerson)
# generate a list filtering out the IDs that are already merged
newIdList=[]
foriinidList:
iflen(i)!=1:
newIdList.append(i)# maintain the ones to be merged
eliflen(i)==1:
ifi[0]notinidListMergedPerson:
newIdList.append(i)
idList=newIdList
# update ID of the reference person
foriindata:
# if the ID is present in entries to be merged
foridNew,doubleinenumerate(idList):
ifi["id"]indoubleandlen(double)==2:# only those with two entries
idOld=i["id"]
# the reference IDs still need to be changed for all of them