0

I have a ppt file and want to save it to my user folder inside the databricks dbfs system. This is what I have:

from pptx import Presentation
from pptx.util import Cm
import shutil

pptx.save(some_name + '.pptx')

Now, I found this command example but I am not sure if its going to work and how to change it to my specifications:

dbutils.fs.put("/FileStore/my-stuff/my-file.txt")

What does FileStore, and my-stuff stand for? Where do I specify my user name to map to my folder?

LaLaTi
  • 1,455
  • 3
  • 18
  • 31

1 Answers1

0

You can use the command to save the ppt file to databricks filesystem.

from pptx import Presentation

prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]

title.text = "Hello, World!"
subtitle.text = "python-pptx was here!"

prs.save('/dbfs/test.pptx')

Sample Notebook:

enter image description here

OR

If you want to save ppt file from local machine to Databricks filesystem, you can use Databricks cli cmdlet.

dbfs cp "A:AzureLearning\AzureDatabricks\BRK4024.pptx" dbfs:/myfolder/BRK4024.pptx

enter image description here

FileStore and my-stuff are the folders inside the databricks filesystem. You can create a new folder with any name and save the your files into that folder. Where in the above databricks CLI example, I have saved the "BRK4024.pptx" file in the folder named "myfolder".

Reference: Getting started with python-pptx

Hope this helps.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
  • this is so great! The last step /question is how to now access this file. Would you also happen to know this? – LaLaTi Nov 12 '19 at 20:47
  • I have responded on your new post: https://stackoverflow.com/questions/58826584/how-to-display-and-download-a-pptx-file-from-databricks/58831651#58831651 – CHEEKATLAPRADEEP Nov 13 '19 at 06:46
  • @CHEEKATLAPRADEEP-MSFT when I run this I get "[Errno 95] Operation not supported" - any ideas how I can get around this? – Alex Nov 05 '21 at 19:54