如何使用 Pandas.read_excel 在内存中打开 XLS 文件?
How to open in memory XLS file using Pandas.read_excel?
我有一个文件,我正尝试使用 Pandas.read_excel 打开它。我收到这样的错误 -
无效文件:
InMemoryUploadedFile: file.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
首先你需要用xlrd打开你的文件,然后用参数engine="xlrd"
将结果传递给pandas.read_excel
import pandas as pd
import xlrd
book = xlrd.open_workbook(file_contents=myfile)
df = pd.read_excel(book,engine='xlrd')
print(df.head())
这里"myfile"是你的内存文件
我有一个文件,我正尝试使用 Pandas.read_excel 打开它。我收到这样的错误 -
无效文件:
InMemoryUploadedFile: file.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
首先你需要用xlrd打开你的文件,然后用参数engine="xlrd"
将结果传递给pandas.read_excelimport pandas as pd
import xlrd
book = xlrd.open_workbook(file_contents=myfile)
df = pd.read_excel(book,engine='xlrd')
print(df.head())
这里"myfile"是你的内存文件