def get_orgs(): with open('contacts/data/export.vcf', 'r', encoding='utf-8') as rfh: full_file = rfh.read() raw_cards = full_file.split('BEGIN:VCARD') cards = [] for c in raw_cards: card = {} for line in c.split('\n'): if ':' in line: k, v = line.split(':', 1) if ';' in k: k = k.split(';')[0] card[k] = v cards.append(card) orgs = {} for c in cards: if 'FN' in c and 'ORG' in c: orgs[c['FN']] = c['ORG'].split(';') return orgs if __name__ == '__main__': print(get_orgs())