Created
December 31, 2011 11:43
-
-
Save raptium/1543762 to your computer and use it in GitHub Desktop.
Outlook vcf to iCloud vcf
This file contains 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
# -*- 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