InputStream object cannot be used with pandas
@vrdmr đang làm issue này rồi.
Từ ngày 1/6/2021.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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?
- Ngôn ngữ chính
- Python
- Star
- 357
- Fork
- 117
- Merge trung bình
- 13 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-functions-python-worker
-
[Bug] ASGI cookie conversion serializes an absent Domain attribute and breaks __Host- cookiesCó thể đã có người làm @tharun06 đã nhận 23 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
Azure/azure-functions-python-worker#1908 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Azure/azure-functions-python-worker#1906 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
[Python 3.14 proxy worker] Missing sys.modules["__main__"] breaks multiprocessing spawnCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Tất cả issue của Azure/azure-functions-python-worker
Issue tương tự
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
btclib-org/btclib-node#1955 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation v0.9.2
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
khuisman/mcp-gee-sweet#1033 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ossf/cve-bin-tool#5966 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 2 ngày
-
write_iceberg ignores the table's write.parquet.compression-codec propertyCó thể đã có người làm @YuangGao đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Eventual-Inc/Daft#7606 ·
Maintainer thường phản hồi trong vòng 1 ngày