daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # foreign keys: master_event_id, calendar_id, account_id
  2.  
  3. import json
  4. from pprint import pprint
  5.  
  6. with open('event-sync-data-2018-09-03.json') as f:
  7.     data_1 = json.load(f)
  8.     data_1 = sorted(data_1, key=lambda k: k['id'])
  9.  
  10. with open('event-sync-data-2018-09-04.json') as f:
  11.     data_2 = json.load(f)
  12.     data_2 = sorted(data_2, key=lambda k: k['id'])
  13.  
  14. common_items = []
  15. data_1_only = []
  16. data_2_only = []
  17.  
  18. while data_1 != []:
  19.     for item_1 in data_1:
  20.         if item_1['id'] < data_2[0]['id']:
  21.             data_1_only.append(item_1)
  22.             data_1 = data_1[1:]
  23.             break
  24.         elif data_2[0]['id'] < item_1['id']:
  25.             data_2_only.append(data_2[0])
  26.             data_2 = data_2[1:]
  27.             break
  28.         elif data_2[0]['id'] == item_1['id']:
  29.             item_2 = data_2[0]
  30.             item_1['master_event_id'] = None
  31.             item_2['master_event_id'] = None
  32.             item_1['calendar_id'] = None
  33.             item_2['calendar_id'] = None
  34.             item_1['account_id'] = None
  35.             item_2['account_id'] = None
  36.            
  37.             common_items.append(item_1)
  38.             data_2 = data_2[1:]
  39.             data_1 = data_1[1:]
  40.  
  41. if data_2 != []:
  42.     data_2_only.extend(data_2)
  43.  
  44. print data_1_only
  45. # print common_items
  46. # print data_2_only
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top