gpt4 book ai didi

python - 使用 Databricks 将 Docx 保存在 Azure Blob 存储中

转载 作者:行者123 更新时间:2023-12-03 03:22:23 27 4
gpt4 key购买 nike

我尝试在 Azure 存储帐户中保存 .docx 文件,但不起作用:

我这样做了:

已安装存储帐户:

storage_account_name = ""
storage_account_access_key = ""
container_name = "docs"
mount_point = "/mnt/my_mount_point"

dbutils.fs.mount(
source=f"wasbs://{container_name}@{storage_account_name}.blob.core.windows.net",
mount_point=mount_point,
extra_configs={f"fs.azure.account.key.{storage_account_name}.blob.core.windows.net": storage_account_key}
)

尝试保存:

from docx import Document

doc = Document()

doc.add_heading('My Document Title', level=1)

temp_file_path = '/dbfs/tmp/docgerada.docx'

*doc.save(temp_file_path)*

destination_path = 'my_mount_point/new_document.docx'

dbutils.fs.cp('file:'+temp_file_path, f'/mnt/{destination_path}')

获取错误:

OSError: [Errno 95] Operation not supported

最佳答案

这有效:

doc.save('/databricks/teste.docx')

destination_path = 'my_mount_point/doc.docx'

dbutils.fs.cp('file:/databricks/teste.docx', f'/mnt/{destination_path}')

关于python - 使用 Databricks 将 Docx 保存在 Azure Blob 存储中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76772076/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com