03-28-2022 05:12 AM
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
03-28-2022 05:56 AM
os.getenv()
method in Python returns the value of the environment variable key if it exists otherwise returns the default value
03-28-2022 05:26 AM
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.
03-28-2022 05:31 AM
******************************************************
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")
03-28-2022 05:33 AM
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
03-28-2022 05:42 AM
can you check this?
https://stackoverflow.com/questions/62953148/saving-file-into-azure-blob
03-28-2022 05:53 AM
Ok I am checking. Quick check, what should be in place of str ?
connect_str = os.getenv('str')
03-28-2022 05:56 AM
os.getenv()
method in Python returns the value of the environment variable key if it exists otherwise returns the default value
03-28-2022 06:23 AM
Wow it works.. Thank you so so much!! Really appreciate your quick help!
04-14-2022 06:26 AM
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!
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.