Skip to content

Commit a20005b

Browse files
committed
Added Capability to add everything in single file
1 parent 8893fe4 commit a20005b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

csv2vcard/csv2vcard.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from csv2vcard.parse_csv import parse_csv
44

55

6-
def csv2vcard(csv_filename: str, csv_delimeter: str):
6+
def csv2vcard(csv_filename: str, csv_delimeter: str, single_file=True):
77
"""
88
Main function
99
"""
1010
check_export()
1111

1212
for c in parse_csv(csv_filename, csv_delimeter):
1313
vcard = create_vcard(c)
14-
export_vcard(vcard)
14+
export_vcard(vcard, single_file)
1515

1616

1717
def test_csv2vcard():
@@ -29,4 +29,4 @@ def test_csv2vcard():
2929
check_export()
3030
vcard = create_vcard(mock_contacts[0])
3131
print(vcard)
32-
export_vcard(vcard)
32+
export_vcard(vcard, single_file=False)

csv2vcard/export_vcard.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import os
22

3-
def export_vcard(vc_final):
3+
def export_vcard(vc_final, single_file):
44
"""
55
Exporting a vCard to /export/
66
"""
77
try:
8-
with open(f"export/{vc_final['filename']}", "w") as f:
8+
file_name = f"export/{vc_final['filename']}" if not single_file else f"export/final_export.vcf"
9+
with open(file_name, "a") as f:
910
f.write(vc_final['output'])
1011
f.close()
1112
print(f"Created vCard 3.0 for {vc_final['name']}.")

0 commit comments

Comments
 (0)