You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the xlwings API does not seem to support file paths that are formatted as pathlib.Path object. The following code example demonstrates this:
# OS: Windows 10# xlwings: 0.15.8# excel: 2013# python: 3.7.3frompathlibimportPathimportxlwingsasxw# Create dummy excel filebook=xw.Book()
book.save('example_file.xlsx')
book.close()
# Attempt to connect to excel file using Pathlib pathfile_path=Path('example_file.xlsx').resolve()
xw.Book(file_path)
The subsequent error traceback is:
AttributeError Traceback (most recent call last)
~\Desktop\example.py in <module>
9 # Attempt to connect to excel file using Pathlib path
10 file_path = Path('example_file.xlsx').resolve()
---> 11 xw.Book(file_path)
C:\Software\Anaconda3\lib\site-packages\xlwings\main.py in __init__(self, fullname, impl)
474 if not impl:
475 if fullname:
--> 476 fullname = fullname.lower()
477
478 candidates = []
AttributeError: 'WindowsPath' object has no attribute 'lower'
The addition of support for pathlib.Path file paths is hereby proposed as enhancement of xlwings.
Rationale
Use of pathlib.Path objects for file paths is attractive to users because (compared to string object file paths) they are usually easier to work with and more consistent across operating systems (see Python 3's pathlib Module: Taming the File System for more details). The pathlib module is readily available, since it is part of python's standard library since version 3.4.
The text was updated successfully, but these errors were encountered:
Previously all path input arguments had to be a string object. Path
input arguments now accept any object that is an instance of
`os.PathLike` as well.
Closes: xlwings#1124
Description
Currently the xlwings API does not seem to support file paths that are formatted as
pathlib.Path
object. The following code example demonstrates this:The subsequent error traceback is:
The addition of support for
pathlib.Path
file paths is hereby proposed as enhancement of xlwings.Rationale
Use of
pathlib.Path
objects for file paths is attractive to users because (compared to string object file paths) they are usually easier to work with and more consistent across operating systems (see Python 3's pathlib Module: Taming the File System for more details). Thepathlib
module is readily available, since it is part of python's standard library since version 3.4.The text was updated successfully, but these errors were encountered: