โ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 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