Created
April 16, 2013 14:47
-
-
Save c7h/5396518 to your computer and use it in GitHub Desktop.
CSV to VCARD
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
#!/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