Skip to content

Commit e332a79

Browse files
committed
add sep to kv_to_csv
1 parent 9fb7d22 commit e332a79

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

textractor/entities/page.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ def export_kv_to_csv(
764764
include_kv: bool = True,
765765
include_checkboxes: bool = True,
766766
filepath: str = "Key-Values.csv",
767+
sep: str = ",",
767768
):
768769
"""
769770
Export key-value entities and checkboxes in csv format.
@@ -774,6 +775,8 @@ def export_kv_to_csv(
774775
:type include_checkboxes: bool
775776
:param filepath: Path to where file is to be stored.
776777
:type filepath: str
778+
:param sep: Separator to be used in the csv file.
779+
:type sep: str
777780
"""
778781
keys = []
779782
values = []
@@ -792,9 +795,9 @@ def export_kv_to_csv(
792795
values.append(kv.value.children[0].status.name)
793796

794797
with open(filepath, "w") as f:
795-
f.write(f"Key,Value{os.linesep}")
798+
f.write(f"Key{sep}Value{os.linesep}")
796799
for k, v in zip(keys, values):
797-
f.write(f"{k},{v}{os.linesep}")
800+
f.write(f"{k}{sep}{v}{os.linesep}")
798801

799802
logging.info(
800803
f"csv file stored at location {os.path.join(os.getcwd(), filepath)}"

0 commit comments

Comments
 (0)