I'm looking for a better and simpler solution to find changes between two nested lists within dicts, archived and actual data.
I want to find:
added data in actual data
deleted data from actual data
changes inside data -search by
id
values (unique number for data)
self.l_dicts_arch
- archived data
self.l_dicts_actual
- actual data
Here's my function:
def check(self):
for item in self.l_dicts_arch:
if item in self.l_dicts_actual:#remove correct data
self.l_dicts_actual.remove(item)
elif item not in l_dicts_actual:
for item2 in l_dicts_actual:
if item['id']==item2['id']:#display and remove data with error
print 'Found error in data'
print 'from first list', item
print 'from second list',item2
actual_list.remove(item2)
else:
print 'This item was removed from actual list'#display deleted data
print item
if len(self.l_dicts_actual)!=0:
print 'This item was added on actual list'
for item in self.l_dicts_actual:
print item