问题:
我正在使用 pd.read_excel 打开 .xls,但出现错误。
df_cima = pd.read_excel("docs/Presentaciones.xls")
xlrd.biffh.XLRDError: Excel xlsx file; not supported
Run Code Online (Sandbox Code Playgroud)
该文件的后缀是 .xls 但此错误告诉我它是 .xlsx
然后我尝试添加engine="openpyxl",它通常用于当 xlrd 版本不再是 1.2.0 时读取 .xlsx ,然后它给了我另一个错误
openpyxl.utils.exceptions.InvalidFileException: openpyxl does not support the old .xls file format, please use xlrd to read this file, or convert it to the more recent .xlsx file format.
Run Code Online (Sandbox Code Playgroud)
我的环境:
我不想将 xlrd 版本更改回 1.2.0,从其他答案中我看到新版本的 xlrd 仅支持 .xls,但我不明白为什么它不适用于我的文件。
提前致谢。
问题:
我有一个文件夹(json_folder_large),其中包含 200, 000 多个 json 文件,另一个文件夹(json_folder_small),其中包含 10, 000 个 json 文件。
import os
lst_file = os.listdir("tmp/json_folder_large") # this returns an OSError
OSError: [Errno 5] Input/output error: 'tmp/json_folder_large'
Run Code Online (Sandbox Code Playgroud)
当我将 listdir 与目录路径一起使用时,出现 OSError 。我确信路径没有问题,因为我可以对其他文件夹执行相同的操作,而不会出现此 OSError。
lst_file = os.listdir("tmp/json_folder_small") # no error with this
Run Code Online (Sandbox Code Playgroud)
环境:
上面的问题是docker 镜像作为 pycharm 解释器。
当解释器是conda env时,没有错误。
我能看到的唯一区别是,在我的 docker/preferences/resources/advanced 中,我设置了 4 个 CPU(最大为 6)和 32GB 内存(最大为 64)。
我尝试过:(在docker下)
1.使用Pathlib
import pathlib
pathlib.Path('tmp/json_folder_large').iterdir() # this returns a generator …Run Code Online (Sandbox Code Playgroud)