Programmatically create Databricks Notebook

wesg2
New Contributor

I am creating a databricks notebook via string concats (sample below)

Notebook_Head = """# Databricks notebook source
# from pyspark.sql.types import StringType
# from pyspark.sql.functions import split

# COMMAND ----------
"""
Full_NB = Notebook_Head + Mid + Tail
 
I am using dbutils.fs.put() to write to a storage location.
When I then try to import that file as a NB in databricks it displays as one large text file, NOT as a Databricks Notebook. 
Line 1 = # Databricks notebook source
 
The notebook does not break up into command cells even though I have the proper # COMMAND ----------