“Must explicitly set engine if not passing in buffer or path for io” in Panda

爷,独闯天下 提交于 2019-12-23 15:39:27

问题


When running the following Python Panda code:

    xl          = pd.ExcelFile(dataFileUrl)
    sheets      = xl.sheet_names
    data        = xl.parse(sheets[0])
    colheaders  = list(data)

I receive the ValueError:

Must explicitly set engine if not passing in buffer or path for io

The file is for sure an excel file, no doubt about that.

What is happening?


回答1:


I would try

xl = pd.ExcelFile(dataFileUrl, engine='xlrd')



回答2:


I had this same problem and it was because the code that generated dataFileUrl produced a list with only one element in it. Changing to dataFileUrl[0] fixed the problem.




回答3:


If you give your file path as:

#Read and write to excel
dataFileUrl = R"D:\\real_names.xlsx"
data = pd.read_excel(dataFileUrl)

it will possibly work. I have tried and tested.



来源:https://stackoverflow.com/questions/42950045/must-explicitly-set-engine-if-not-passing-in-buffer-or-path-for-io-in-panda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!