8000 support pathlib in cookbook, #263 · pyexcel/pyexcel@e2d4b5a · GitHub
[go: up one dir, main page]

Skip to content

Commit e2d4b5a

Browse files
committed
support pathlib in cookbook, #263
1 parent 912743a commit e2d4b5a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pyexcel/cookbook.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from pyexcel.book import Book
1414
from pyexcel.core import save_as, get_book, get_sheet
15-
from pyexcel._compact import OrderedDict
15+
from pyexcel._compact import OrderedDict, get_string_file_name
1616
from pyexcel.constants import MESSAGE_WARNING
1717

1818
DEFAULT_OUT_FILE = "pyexcel_merged.csv"
@@ -32,9 +32,10 @@ def update_columns(in_file_name, column_dicts, out_file_name=None):
3232
3333
3434
"""
35+
in_file_name = get_string_file_name(in_file_name)
3536
default_out_file = OUT_FILE_FORMATTER % in_file_name
3637
if out_file_name:
37-
default_out_file = out_file_name
38+
default_out_file = get_string_file_name(out_file_name)
3839
if os.path.exists(default_out_file):
3940
raise NotImplementedError(MESSAGE_WARNING)
4041
sheet = get_sheet(file_name=in_file_name, name_columns_by_row=0)
@@ -54,9 +55,10 @@ def update_rows(in_file_name, row_dicts, out_file_name=None):
5455
:param dict row_dicts: dictionaries of rows
5556
:param str out_file_name: save the sheet as
5657
"""
58+
in_file_name = get_string_file_name(in_file_name)
5759
default_out_file = OUT_FILE_FORMATTER % in_file_name
5860
if out_file_name:
59-
default_out_file = out_file_name
61+
default_out_file = get_string_file_name(out_file_name)
6062
if os.path.exists(default_out_file):
6163
raise NotImplementedError(MESSAGE_WARNING)
6264
sheet = get_sheet(file_name=in_file_name, name_rows_by_column=0)
@@ -71,6 +73,7 @@ def merge_files(file_array, out_file_name=DEFAULT_OUT_FILE):
7173
"""merge many files horizontally column after column
7274
:param str out_file_name: save the sheet as
7375
"""
76+
out_file_name = get_string_file_name(out_file_name)
7477
if os.path.exists(out_file_name):
7578
raise NotImplementedError(MESSAGE_WARNING)
7679
content = []
@@ -90,6 +93,7 @@ def merge_two_files(file1, file2, out_file_name=DEFAULT_OUT_FILE):
9093
:param str file2: an accessible file name
9194
:param str out_file_name: save the sheet as
9295
"""
96+
out_file_name = get_string_file_name(out_file_name)
9397
if os.path.exists(out_file_name):
9498
raise NotImplementedError(MESSAGE_WARNING)
9599
files = [file1, file2]
@@ -102,6 +106,7 @@ def merge_readers(reader_array, out_file_name=DEFAULT_OUT_FILE):
102106
With FilterableReader and SeriesReader, you can do custom filtering
103107
:param str out_file_name: save the sheet as
104108
"""
109+
out_file_name = get_string_file_name(out_file_name)
105110
if os.path.exists(out_file_name):
106111
raise NotImplementedError(MESSAGE_WARNING)
107112
content = OrderedDict()

0 commit comments

Comments
 (0)
0