Skip to content

Commit 62c1905

Browse files
FEAT: Added Create functionality to append mode of ExcelWriter when file doesn't exist
1 parent 1da0d02 commit 62c1905

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pandas/io/excel/_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,11 @@ def __init__(
12541254
ext = os.path.splitext(path)[-1]
12551255
self.check_extension(ext)
12561256

1257+
# If file does not exist, and in append mode, switch to write mode.
1258+
if isinstance(path, str) and "a" in mode and not os.path.exists(path):
1259+
mode = mode.replace("a", "w")
1260+
if_sheet_exists = None
1261+
12571262
# use mode to open the file
12581263
if "b" not in mode:
12591264
mode += "b"

0 commit comments

Comments
 (0)