Created
June 19, 2020 12:45
-
-
Save fcayci/fb8883d0eae345fa9ce037955ee8722b to your computer and use it in GitHub Desktop.
vcard to abook conversion for mal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('contacts.vcf') as f: | |
r = f.read() | |
contacts = r.split('VCARD') | |
with open('out.csv', 'w') as f: | |
for c in contacts: | |
if 'FN:' in c: | |
x = c.strip().split('FN:') | |
y = x[1].strip().split('N:') | |
name = y[0].strip() | |
try: | |
y = x[1].split('@') | |
z = y[0].split(':') | |
add = z[-1] | |
add += '@' | |
z = y[1].split('\n') | |
add += z[0] | |
print(name, add) | |
s = name + ',' + add + '\n' | |
f.write(s) | |
except: | |
#print(name, 'does not have e-mail') | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment