问题
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