Export and import Databricks notebooks
Databricks can import and export notebooks in the following formats:
- Source file: A file containing only source code statements with the extension
.scala,.py,.sql, or.r. - HTML: An Azure Databricks notebook with the extension
.html. - Databricks
.dbcarchive. - IPython notebook: A Jupyter notebook with the extension
.ipynb. - RMarkdown: An R Markdown document with the extension
.Rmd.
Import a notebook
You can import an external notebook from a URL or a file. You can also import a ZIP archive of notebooks exported in bulk from an Azure Databricks workspace.
Click
Workspace in the sidebar. Do one of the following:Next to any folder, click the
on the right side of the text and select Import.In the Workspace or a user folder, click
and select Import.
Specify the URL or browse to a file containing a supported external format or a ZIP archive of notebooks exported from an Azure Databricks workspace.
Click Import.
- If you choose a single notebook, it is exported in the current folder.
- If you choose a DBC or ZIP archive, its folder structure is recreated in the current folder and each notebook is imported.
Import a file and convert it to a notebook
You can convert Python, SQL, Scala, and R scripts to single-cell notebooks by adding a comment to the first cell of the file:
Python
# Databricks notebook source
SQL
-- Databricks notebook source
Scala
// Databricks notebook source
R
# Databricks notebook source
To define cells in a script, use the special comment shown below. When you import the script to Databricks, cells are created as marked by the COMMAND lines shown.
Python
# COMMAND ----------
SQL
-- COMMAND ----------
Scala
// COMMAND ----------
R
# COMMAND ----------
Export notebooks
Note
When you export a notebook as HTML, IPython notebook (.ipynb), or archive (DBC), and you have not cleared the command outputs, the outputs are included in the export.
To export a notebook, select File > Export in the notebook toolbar and select the export format.
To export all folders in a workspace folder as a ZIP archive:
- Click
Workspace in the sidebar. Do one of the following:
- Next to any folder, click the
on the right side of the text and select Export. - In the Workspace or a user folder, click
and select Export.
- Next to any folder, click the
- Select the export format:
- DBC Archive: Export a Databricks archive, a binary format that includes metadata and notebook command outputs.
- Source File: Export a ZIP archive of notebook source files, which can be imported into an Azure Databricks workspace, used in a CI/CD pipeline, or viewed as source files in each notebook’s default language. Notebook command outputs are not included.
- HTML Archive: Export a ZIP archive of HTML files. Each notebook’s HTML file can be imported into an Azure Databricks workspace or viewed as HTML. Notebook command outputs are included.
Feedback
Submit and view feedback for