InputStream object cannot be used with pandas
@vrdmr 已经在做这个了。
开始于 2021年6月1日。
评估
这个 Issue 还没有评估数据。
描述
In this example:
import logging
import os
from azure.cosmosdb.table.tableservice import TableService
import azure.functions as func
import pandas
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
df = pandas.read_excel(myblob, index_col=0)
table_service = TableService(account_name=os.getenv('TABLE_STORAGE_ACCOUNT_NAME'),
account_key=os.getenv('TABLE_STORAGE_KEY'))
records = df.to_dict(orient="records")
for record in records:
table_service.insert_entity('ais', record)
Configured with function.json as:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "ais/{name}.xlsx",
"connection": "anthonyshawstorage_STORAGE"
}
]
}
The script fails because InputStream does not implement the seek function. It does implement seakable() as returning false, which is correct, but pandas doesn't adhere to that API so you get this error:
Exception while executing function: Functions.BlobTrigger Result: Failure
Exception: UnsupportedOperation: seek
Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 542, in __run_sync_func
return func(**params)
File "/home/site/wwwroot/BlobTrigger/__init__.py", line 13, in main
df = pandas.read_excel(myblob, index_col=0)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pandas/util/_decorators.py", line 299, in wrapper
return func(*args, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pandas/io/excel/_base.py", line 336, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pandas/io/excel/_base.py", line 1057, in __init__
ext = inspect_excel_format(
File "/home/site/wwwroot/.python_packages/lib/site-packages/pandas/io/excel/_base.py", line 942, in inspect_excel_format
stream.seek(0)
Technically, this is a bug in pandas, because it should check seekable() first.
Is there a way to make the inputstream seekable if it comes from blob storage?
- 主要语言
- Python
- 星标
- 357
- 派生
- 117
- 平均合并
- 13 天 12 小时
- 30 天内合并 PR
- 2
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/azure-functions-python-worker 的其他 Issue
-
[Bug] ASGI cookie conversion serializes an absent Domain attribute and breaks __Host- cookies可能已有人在做 @tharun06 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 5/5 一周以上 新手友好度 28/100
Azure/azure-functions-python-worker#1908 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 55/100
Azure/azure-functions-python-worker#1906 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
-
[Python 3.14 proxy worker] Missing sys.modules["__main__"] breaks multiprocessing spawn可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
查看 Azure/azure-functions-python-worker 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
Deltares/imod-python#1940 ·
维护者通常 1 天内回复
-
effort: low prio: low ready
难度 1/5 1 小时以内 新手友好度 82/100
digitalfabrik/integreat-cms#4621 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
ioos/compliance-checker#1375 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复