compare multiple list of dicts and avoid duplicates Requirement need to insert data only if readid doesn't exist in payload
old_data= [
{
"abc": "205",
"xyz": "11.38",
"ReadId": "120"
},
{
"abc": "201",
"xyz": "11.38",
"ReadId": "121"
},
{
"abc": "109",
"xyz": "11.38",
"ReadId": "122"
}
]
payload= [
{
"reading_id": 120,
"abc": 205
},
{
"reading_id": 121,
"abc": 199
},
{
"reading_id": 123,
"abcl": 128
}
]
here, is the code I tried but didn't find luck
for d in payload:
for dt in old_data:
if 'ReadId' in data:
if data['ReadId'] != payload['reading_id']:
insertGluco(d['reading_id'])
any help will be appreciated, thank you.