python compare tuples and dictionary -


i have compare 2 sets , find differences in python:

>>> mysql_orders = ((50434l, 5901l), (50733l, 5901l)) >>> opera_orders = [{'orderid': 'web050434', 'accountid': '00t001'}, {'orderid': 'web050733', 'accountid': '00t001'}, {'orderid': 'doc075185', 'accountid': '00t001'}, {'orderid': 'web081859', 'accountid': '00t001'}] 

one list of tuples , other list of dictionaries first item in list orederid without web / doc prefix.

what correct way find missing orderid's not in mysql_orders list?

with regex strip off alphabets, provided numbers come later,

import re  mysql_orders = ((50434l, 5901l), (50733l, 5901l))  opera_orders = [{'orderid': 'web050434', 'accountid': '00t001'}, {'orderid': 'web050733', 'accountid': '00t001'}, {'orderid': 'doc075185', 'accountid': '00t001'}, {'orderid': 'web081859', 'accountid': '00t001'}]  mysql_orders = [element tupl in mysql_orders element in tupl]  missing_order_ids = [opera_order['orderid'] opera_order in opera_orders if long(re.split('\d+', opera_order['orderid'])[1]) not in mysql_orders]  print missing_order_ids 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -