怪我咯2017-04-18 09:40:44
I think stringIO can solve your problem. Use it to save the file.stream content first. Passing to pd.
PHP中文网2017-04-18 09:40:44
.xls
It is not a text file, and setting the encoding should be invalid.
Hold on and wait until the file is downloaded before pd.read_excel()
read_excel(io
) io
) io
可以是 url、ftp 之类的资源定位符。
如果你知道.xls
io
can be a resource locator such as url or ftp.
>>>help(pd.read_excel)
Help on function read_excel in module pandas.io.excel:
read_excel(io, …………)
Read an Excel table into a pandas DataFrame
Parameters
----------
io : string, path object (pathlib.Path or py._path.local.LocalPath),
file-like object, pandas ExcelFile, or xlrd workbook.
The string could be a URL. Valid URL schemes include http, ftp, s3,
and file. For file URLs, a host is expected. For instance, a local
file could be file://localhost/path/to/workbook.xlsx
🎜Try it, directly pd.read_excel(file) or (file.stream)🎜
file = request.files['files']
taxidata_from_excel = pd.read_excel(file) # (file.stream)