cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Powerpoint file operations in Databricks

AJ270990
Contributor II

Hi Team, I am writing a python code in Azure Databricks where I have mounted a Azure storage and accessing the input dataset from Azure storage resource. I am accessing the input data from Azure storage and generating charts from that data in databricks workbook. All the input files are on AZ storage. I have placed the generated charts into powerpoint but unable to save that updated powerpoint file back to Azure storage. I have tried using the object of Presentation() and tried saving the file using .sav(), but it saves in local workspace of databricks and not on mounted storage. Please help

1 ACCEPTED SOLUTION

Accepted Solutions

-werners-
Esteemed Contributor III

os.getenv()

method in Python returns the value of the environment variable key if it exists otherwise returns the default value

View solution in original post

8 REPLIES 8

-werners-
Esteemed Contributor III

can you share the code where you do the actual write?

The fact that you save a powerpoint makes me think you do not use the Spark environment, but plain python.

******************************************************
 
from pptx import Presentation
 
from pptx.util import Inches, Pt 
 
 
 
prs = Presentation('/dbfs/mnt/powerpoint-templates/MAPresentation.pptx')
 
#First slide - Index 0
 
slide = prs.slides.add_slide(prs.slide_layouts[0])
 
 
 
# Add a picture to the given dimensions
 
slide.placeholders[14].insert_picture('/dbfs/mnt/powerpoint-templates/page_type_transaction_barplot.png')
 
 
 
prs.save("/dbfs/mnt/powerpoint-templates/MA_presentation_New.pptx")

Yes I am using python environment and not spark.

These operations are of python.

The last line.. prs.save() is giving an error.

When I do normal prs.save(file name) without the path it works and save the file in current workspace. But that is of no use. I want the file to be saved on Blob storage

-werners-
Esteemed Contributor III

Ok I am checking. Quick check, what should be in place of str ?

connect_str = os.getenv('str')

-werners-
Esteemed Contributor III

os.getenv()

method in Python returns the value of the environment variable key if it exists otherwise returns the default value

AJ270990
Contributor II

Wow it works.. Thank you so so much!! Really appreciate your quick help!

Anonymous
Not applicable

Hi @Abhishek Jainโ€‹ 

Thanks for sending in your query. We are glad that you found a solution. Would you like to mark the answer as best so the other members can benefit from it too?

Cheers!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group