I\'m trying to open a file in Python, but I got an error, and in the beginning of the string I got a /u202a
character... Does anyone know how to remove it?
you can use this sample code to remove u202a from file path
st="F:\\somepath\\filename.xlsx"
data = pd.read_excel(st)
if i try to do this it gives me a OSError and In detail
Traceback (most recent call last):
File "F:\CodeRepo\PythonWorkSpace\demo\removepartofstring.py", line 14, in
data = pd.read_excel(st)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\util\_decorators.py", line 188, in wrapper
return func(*args, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\util\_decorators.py", line 188, in wrapper
return func(*args, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\excel.py", line 350, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\excel.py", line 653, in __init__
self._reader = self._engines[engine](self._io)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\excel.py", line 424, in __init__
self.book = xlrd.open_workbook(filepath_or_buffer)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\xlrd\__init__.py", line 111, in open_workbook
with open(filename, "rb") as f:
OSError: [Errno 22] Invalid argument: '\u202aF:\\somepath\\filename.xlsx'
but if i do that like this
st="F:\\somepath\\filename.xlsx"
data = pd.read_excel(st.strip("u202a")) #replace your string here
Its working for me