Created
June 21, 2010 16:30
-
-
Save Siim/447107 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option( | |
"-f","--file", | |
dest="filename", | |
help="Convert TomTom CSV contacts to VCF", | |
metavar="FILE" | |
) | |
(options, args) = parser.parse_args() | |
f = open(options.filename, 'r') | |
for line in f: | |
# remove tomtom group name? | |
line = line.replace("(mobile)","") | |
l = line.split(",") | |
# get contact info | |
contact = {'name': l[0].strip('"'), 'number':l[1].strip('"') } | |
# construct vcard | |
vc = [ | |
"BEGIN:VCARD\r\n", | |
"N:;",contact['name'],";;;\r\n", | |
"TEL;TYPE=CELL:",contact['number'],"\r\n", | |
"UID:",contact['number'],"\r\n" | |
"VERSION:2.1\r\n", | |
"END:VCARD\r\n" | |
] | |
# output > file etc... | |
print "".join(vc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment