Skip to content

Instantly share code, notes, and snippets.

@c7h c7h/gist:5396518
Created Apr 16, 2013

Embed
What would you like to do?
CSV to VCARD
#!/usr/bin/python
import sys
import csv
def convert(filename):
reader = csv.reader(open(filename, 'rb'))
for row in reader:
lastname = row[0]
firstname = row[1]
mail = row[2]
tel = row[3]
print 'BEGIN:VCARD'
print 'VERSION:2.1'
print 'N:%s;%s' % (lastname, firstname)
print 'FN:%s %s' % (firstname, lastname)
print 'TEL;HOME;VOICE:' + tel
print 'EMAIL;PREF;INTERNET:'+mail
print 'END:VCARD'
if __name__ == "__main__":
args = sys.argv
if len(args) != 2:
print "Usage:"
print args[0] + " filename"
else:
convert(args[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.