Skip to content

Commit

Permalink
fix : minor edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sepandhaghighi committed Jul 5, 2017
1 parent b54820f commit f1e56ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion csv2vcf/VCF.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def time_convert(input_data):
def VCF_creator(first_name,last_name,tel_mobile,tel_home,tel_work,email_home,email_work,email_mobile):
if "VCF_CONVERT" not in os.listdir():
os.mkdir("VCF_CONVERT")
file=open(os.path.join("VCF_CONVERT",last_name+"_"+first_name+".vcf"),"a")
file=open(os.path.join("VCF_CONVERT",last_name+"_"+first_name+".vcf"),"w")
file.write("BEGIN:VCARD\n")
file.write("VERSION:3.0\n")
file.write("N:"+last_name+";"+first_name+";;;"+"\n")
Expand All @@ -50,6 +50,7 @@ def csv_reader(file_name):
try:
file=open(file_name,"r")
unknown_index=0
vcf_counter=0
for index,line in enumerate(file):
if index>0:
stripped_line=line.strip()
Expand All @@ -63,6 +64,9 @@ def csv_reader(file_name):
VCF_creator("Unknown ",str(unknown_index),temp[2],temp[3],temp[4],temp[5],temp[6],temp[7])
else:
VCF_creator(temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7])
vcf_counter+=1
return vcf_counter

except Exception as e:
print("[Error] In Reading CSV File")

4 changes: 2 additions & 2 deletions csv2vcf/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
if __name__=="__main__":
if "contact.csv" in os.listdir():
time_1=time.perf_counter()
csv_reader("contact.csv")
counter=csv_reader("contact.csv")
time_2=time.perf_counter()
delta_time=time_2-time_1
print("VCF Data Generated In " + time_convert(delta_time))
print(str(counter)+" VCF File Generated In " + time_convert(delta_time))
else:
print("[Error] There is no csv input file")

0 comments on commit f1e56ca

Please sign in to comment.