cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.