pandas - IOError although file name is correct and in the same folder
问题描述
I imported an Excel file (.xlsx) with pandas, and it worked great.
Then, I tested my code with a copy of the same file (I changed something in its content to test something). I named it differently, and changed the name of the file in the code as well, and it worked great.
HOWEVER NOW - I tried to import the original file again (I didn't forget to change the name in the code as well) - and it doesn't recognizes it anymore!
I checked many times that the name of the file is identical to the one I wrote in the code, and that the .py file is in the same folder as the .xlsx file - I don't get it - why doesn't it work anymore?
Please look at the attached screenshot, where you can see the code, and also the actual file name and that the files are in the same folder (left side of the screenshot)
Please help me understand and fix the situation.
Thank you!
p.s - the "Invalid file name" message is what I wrote in the 'except' block after the 'try' block.
except IOError:
print("Invalid file name")
[Screenshot showing file name matches in code + excel file and python file in the same folder][1]
[1]: https://i.stack.imgur.com/FPWhM.pngstrong text
解决方案
RESOLVED
Has something to do with Right to Left languages aka Hebrew and Arabic... If your language is one of these and you face the same problem - try what I did
How I found out and what I did to fix it: I tried to rewrite the file name, and when I started deleting it, I noticed the typing pointer is facing the left side (like in languages that write Right to Left).. After deleting the entire file name I made sure my keyboard is set to English (my native language is Hebrew, which is Right to Left) - although as you saw, I did wrote the file name in English - weird... And then I wrote the file name again - exactly the same - and it worked! Apparently some bug regarding RtL languages...
Hope it'll help someone in the future, or that Pycharm will fix the issue...
推荐阅读
- docker - Nexus 存储库管理器 docker 升级
- iframe - 当我在 JSFiddle 中添加 iframe 时,为什么 onmousedown 会停止触发?
- android - 如何更新 Rest Api URL?
- python - 如何通过共享一个轴制作多个散点图?
- python - 有没有一种很好的方法可以使它成为一个 for 循环?
- java - Java 流将对象 List 的每个属性设置为另一个 List
- gitlab-ci - 从 Gitlab CI 工作流部署到 Maven Central
- javascript - 将选中的 ng-repeat 值(复选框为真)作为数组参数发送到 javascript 函数中
- sql - 加快大型 Oracle 数据库中的 Oracle SQL Developer 查询
- c# - C#:从已知数量的构造函数中调用随机构造函数的聪明方法是什么?