Skip to content

Instantly share code, notes, and snippets.

@fcayci
Created June 19, 2020 12:45
Show Gist options
  • Save fcayci/fb8883d0eae345fa9ce037955ee8722b to your computer and use it in GitHub Desktop.
Save fcayci/fb8883d0eae345fa9ce037955ee8722b to your computer and use it in GitHub Desktop.
vcard to abook conversion for mal
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