Skip to content

Instantly share code, notes, and snippets.

@Siim
Created June 21, 2010 16:30
Show Gist options
  • Save Siim/447107 to your computer and use it in GitHub Desktop.
Save Siim/447107 to your computer and use it in GitHub Desktop.
#!/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