使用Databricks将Docx保存在Azure Blob存储中[重复]

eqfvzcg8  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(132)

此问题在此处已有答案

Pandas: Write to Excel not working in Databricks(1个答案)
11天前关闭。
我试图将.docx文件保存在azure存储帐户中,但不起作用:
我这样做:

挂载存储账号:

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

ryoqjall

ryoqjall1#

这是有效的:

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

destination_path = 'my_mount_point/doc.docx'

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

字符串

相关问题