如何显示和下载来自databricks的pptx文件? [英] How to display and download a pptx file from databricks?

查看:129
本文介绍了如何显示和下载来自databricks的pptx文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Python在数据块中使用实用程序脚本生成了一个Power Point平台。我现在想在内核中访问文件,但是由于甲板上的图像,它显示了奇怪的符号。

  #access文件
dbutils.fs.head('文件:/dbfs/user/test.pptx')

出:'PK\x03\x04\x14\x00\x00\x00\x08\x00D lOƯ gx0101x00x00x0cx00x00x13x00x0000x00 [Content_Types].xml͗N0x10* E K\x0e q \x175 rb \x04< I -ϴзg..R \n_\x12 3 ''Q4霼 :\x1a GeM l $ \x02 B A ]] x0e \x08I Bjk K& Iw s7q qx11\x17\ x1b ! ; \x16\x02 !


解决方案


如何显示来自databricks的pptx文件?


要使用以下代码显示来自databricks的pptx文件:



来自pptx导入的

 演示文稿
prs = Presentation('/ dbfs / myfolder / BRK4024.pptx')
for幻灯片中的幻灯片:
用于slide.shapes中的形状:
print(shapes.shape_type)
print('----------------')
如果是shapes。 has_text_frame:
print(shapes.text)

笔记本示例:





注意:在输出中,您将看到(



希望这会有所帮助。


I generated a power point deck with a utility script in databricks using Python. I want to access the file now in the kernel but due to the images in the deck, it shows strange symbols. How do I correct this statement which outputs the deck image?

#access file
dbutils.fs.head('file:/dbfs/user/test.pptx')

Out: 'PK\x03\x04\x14\x00\x00\x00\x08\x00D�lOƯ�g�\x01\x00\x00�\x0c\x00\x00\x13\x00\x00\x00[Content_Types].xml͗�N�0\x10��<E�K\x0e�q�\x175��rb�\x04<�I����-ϴзg�.��R�\n_\x12�3���\'Q4霼�:\x1a�GeM�l��$\x02��B�A���]�\x0e�\x08I�Bjk K&��Iw�s7q�\x11\x17\x1b��!�;\x16\x02�!

解决方案

How to display a pptx file from databricks?

To display a pptx file from databricks using below code:

from pptx import Presentation
prs = Presentation('/dbfs/myfolder/BRK4024.pptx')
for slide in prs.slides:
  for shapes in slide.shapes:
    print( shapes.shape_type )
    print( '----------------' )
    if shapes.has_text_frame:
      print( shapes.text )

Notebook sample:

Note: In the output you will see ("PlaceHolders", "AutoShapes", "Pictures") because python-pptx does not support SmartArt. You need to manually insert content into a placeholder/AutoShapes/Pictures, which will be overhead task to build in python.

Example: Sample code - add an image in every Powerpoint slide using python-pptx

How to download a pptx file from databricks?

You can use databricks cli to download files from databricks file system to local machine as follows;

dbfs cp dbfs:/myfolder/BRK4024.pptx A:DataSet\

Example: Since I have a sample BRK4024.pptx file in myfolder on dbfs, I'm using databricks cli command to copy to local machine folder name (A:Dataset)

Hope this helps.

这篇关于如何显示和下载来自databricks的pptx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆