【发布时间】:2020-11-17 02:50:42
【问题描述】:
遵循上一个堆栈溢出问题Azure Function - Pandas Dataframe to Excel 的答案后,我已经能够将 xlsx 文件存储在存储 blob 中,但该文件为空。我在本地使用 Azurite 进行调试,所以我可以看到数据框不为空,outputblob 对象也不为空,但存储容器中生成的 .xlsx 文件是 0 字节文件。
这是我正在运行的相关“写入 blob”代码。
# Write data to storage blob
df = pd.DataFrame(all_data, columns=COLUMN_NAMES)
if not df.empty:
xlb = io.BytesIO()
writer = pd.ExcelWriter(xlb, engine= 'xlsxwriter') # pylint: disable=abstract-class-instantiated
df.to_excel(writer, index=False)
xlb.seek(0)
outputblob.set(xlb)
logging.info(f"Write OK. Number of rows: {df.shape[0]} ")
这里是来自function.json 的绑定部分:
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 2 * * * *"
},
{
"type": "blob",
"direction": "out",
"name": "outputblob",
"path": "performance-alerting-data/SignInApp/outputblob.xlsx",
"connection": "AzureWebJobsStorage"
}
【问题讨论】:
标签: python excel pandas azure-functions azure-blob-storage