Skip to content

Instantly share code, notes, and snippets.

@raptium
Created December 31, 2011 11:43
Show Gist options
  • Save raptium/1543762 to your computer and use it in GitHub Desktop.
Save raptium/1543762 to your computer and use it in GitHub Desktop.
Outlook vcf to iCloud vcf
# -*- coding: utf-8 -*-
def print_entry(name, tel):
tmpl = '''BEGIN:VCARD
VERSION:3.0
N:%s;%s;;;
FN:%s %s
TEL;TYPE=CELL;TYPE=pref;TYPE=VOICE:%s
END:VCARD'''
last = name[0].encode('utf-8')
first = name[1:].encode('utf-8')
print tmpl % (last, first, first, last, tel)
def convert():
with open('a.vcf', 'r') as f:
for line in f:
if line[:2] == 'N:': # name
name = line[2:].strip().decode('gbk')
if line[:3] == 'TEL': # tel
tel = line.split(':')[-1].strip()
print_entry(name, tel)
def main():
convert()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment