无法对传出类型数据进行编码:Python 类型 "DataFrame" 不支持的类型"<class 'azure_functions_worker.bindings.generic.Gener



我正试图通过SAS密钥将我访问过的文件上传到azure Blob存储。正如你所看到的,我已经为此使用了BlobTrigger。我不知道如何处理这个错误,也不知道如何将其转换为DataFrame(我已经尝试过转换为Panda数据帧(。我也读过微软文档,也许我漏掉了一点。

我得到的错误:

失败异常:TypeError:无法对传出的TypedData进行编码:不支持的类型"lt;类'azure_functions_worker.bindings.generic.GenericBinding'>quot;对于Python类型";DataFrame";

基本上我正在读取Excel文件,我想将Excel文件写回另一个容器。

函数.Json文件:

{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "input/{name}.xlsx",
"connection": "AzureWebJobsStorage"
},
{
"name": "outputblob",
"type": "blob",
"path": "output/{name}",
"connection": "AzureWebJobsStorage",
"direction": "out"
}
],
"disabled": false
}

init.py文件:

def main(myblob: func.InputStream, outputblob: func.Out[bytes]):
def read_excel_files(_container, _filename):
sas = generate_SAS(f"{_container}", f"{_filename}")
blob_url = f'https://{account_name}.blob.core.windows.net/{_container}/{_filename}?{sas}'
return pd.read_excel(blob_url)
if myblob.name.__contains__("Book"):
logging.info("Book was found")
Buch = read_excel_files("_container", "_filename.xlsx")
logging.info("Starting cleaning Process")
...
logging.info("Cleaning is finished")        
outputblob.set(Buch)

如另一个问题中所述,以及我必须作为字符串上传到Azure的链接代码。我只发布了我更改的部分代码。

outputblob: func.Out[str]) -> None:
#everything is the same
#Change the your variable to string before uploading
outputblob.set(Buch.to_string())

相关内容

最新更新