# -*- coding: utf-8 -*-#python 3.ximportcsvimportsys#convert a "comma separated values" file to vcf contact cards. I used this to convert a list of student#names and phone numbers into a vcf and save the trouble of adding one by one through phone#USAGE:#CSV_to_Vcards.py CSV_filenamedefconvert(somefile):#assuming file format : lastname,firstname,phonenumber,mailwithopen(somefile,'r')assource:reader=csv.reader(source)#reader now holds the whole data like ['lastname', 'firstname', 'phonenumber', 'mail']allvcf=open('ALL.vcf','w')i=0forrowinreader:#write in the "ALL.vcf" file.allvcf.write('BEGIN:VCARD'+"\n")allvcf.write('VERSION:2.1'+"\n")allvcf.write('N:'+row[0]+';'+row[1]+"\n")allvcf.write('FN:'+"Bootcamp "+row[1]+' '+row[0]+"\n")#remember that lastname firstallvcf.write('ORG:'+'Bootcamp'+"\n")allvcf.write('TEL;CELL:'+row[2]+"\n")allvcf.write('EMAIL:'+row[3]+"\n")allvcf.write('END:VCARD'+"\n")allvcf.write("\n")i+=1#countsallvcf.close()print(str(i)+" vcf cards generated")defmain(args):iflen(args)!=2:print("Usage:")print(args[0]+" filename")returnconvert(args[1])if__name__=='__main__':main(sys.argv)