I'm trying to iterate over a list of dicts and get only the symbol and company name out of it maybe store in another dict, I tried parsing the json file directly and failed. I tried searching all the places I could think of and I'm stumped. Any help is greatly appreciated.
data = [{'symbol': 'ZYME', 'exchange': 'NYS', 'name': 'Zymeworks Inc.', 'date': '2019-11-06', 'type': 'cs', 'iexId': 'IEX_5253315838322D52', 'region': 'US', 'currency': 'USD', 'isEnabled': True}, {'symbol': 'ZYNE', 'exchange': 'NAS', 'name': 'Zynerba Pharmaceuticals Inc', 'date': '2019-11-06', 'type': 'cs', 'iexId': 'IEX_4E3154424A382D52', 'region': 'US', 'currency': 'USD', 'isEnabled': True}, {'symbol': 'ZYXI', 'exchange': 'NAS', 'name': 'Zynex Inc.', 'date': '2019-11-06', 'type': 'cs', 'iexId': 'IEX_4E464C4C4A462D52', 'region': 'US', 'currency': 'USD', 'isEnabled': True}]
spam = {}
def loadWords():
for e in data:
for k, v in e.items():
if k == 'symbol' or k == 'name':
if v not in spam:
spam.update({k:v})
continue
return spam