Download Plotly HTML From Databricks

Viewed 257

I have a plotly figure that I want to download the HTML for. When I try:

fig.to_html()

It will only output some of the HTML string and ends with this:

*** WARNING: skipped 3421789 bytes of output ***

Does anyone know how I can force databricks to show all of the HTML or copy it to my clipboard?

1 Answers

Still a bit hacky, but the following should work to save and download a file from Databricks containing the html:

Assuming you have a plotly figure object and are working in a databricks notebook:

  1. Create an html string and assign a variable to it:
    html_string = fig.to_html()
  1. Save to the databricks filesystem using dbutils:
   dbutils.fs.put("/FileStore/my_html_file.html", html_string)
  1. Download the html string by navigating in a browser to: https://<databricks-instance>/files/my_html_file.html

Note:

  • The databricks instance is usually something like <some_letters>-<some_numbers>.databricks.net
  • If you're within an organisation (i.e. your databricks URLs typically end in "?o=<organisation_id>"), then you may need to add this to the end of the URL in step 3.
Related