<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Call one notebook from another with parameters in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3704715#M1388</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/509497"&gt;@VickyDev18&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its me again. Have you tried using this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; notebookutils &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; mssparkutils&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;mssparkutils.notebook.runMultiple([&lt;/SPAN&gt;&lt;SPAN&gt;"aaa"&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 16 Feb 2024 20:10:43 GMT</pubDate>
    <dc:creator>HimanshuS-msft</dc:creator>
    <dc:date>2024-02-16T20:10:43Z</dc:date>
    <item>
      <title>Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3704252#M1387</link>
      <description>&lt;P&gt;I have this simple notebook to load data from an xlsx file in a lakehouse to a delta table in the Lakehouse.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make this &lt;STRONG&gt;reusable/parameterized&lt;/STRONG&gt; so I call it from another notebook and pass parameters and how exactly would I call it from another notebook?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd

source_path = "/lakehouse/default/"
source_file_name = "Files/Test.xlsx"
sheet_name = "Test"
destination_table = "test"

# Read Excel data into a Pandas DataFrame
df = pd.read_excel(source_path + source_file_name, sheet_name=sheet_name)

# Convert Pandas DataFrame to Spark DataFrame
df_spark = spark.createDataFrame(df)

# Save Spark DataFrame as a Delta table
df_spark.write.mode("overwrite").format("delta").saveAsTable(destination_table)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am aware of how to call a parameterized notebook from a pipeline&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=Rmf7-WOcouE" target="_blank"&gt;How to Pass Parameters from Pipelines to Notebooks in Microsoft Fabric! - YouTube&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I want to know if we can call the notebook from another notebook.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 15:45:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3704252#M1387</guid>
      <dc:creator>VickyDev18</dc:creator>
      <dc:date>2024-02-16T15:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3704715#M1388</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/509497"&gt;@VickyDev18&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its me again. Have you tried using this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; notebookutils &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; mssparkutils&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;mssparkutils.notebook.runMultiple([&lt;/SPAN&gt;&lt;SPAN&gt;"aaa"&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Feb 2024 20:10:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3704715#M1388</guid>
      <dc:creator>HimanshuS-msft</dc:creator>
      <dc:date>2024-02-16T20:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3706794#M1389</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/509497"&gt;@VickyDev18&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for using Fabric Community.&lt;BR /&gt;You can call one notebook from another notebook using %run command. I have created a repro of the same but instead I used a CSV file. I have attached the screenshots of the code.&lt;BR /&gt;&lt;BR /&gt;Functions is my child notebook where I am defining a function to create a table inside lakehouse using the data inside a CSV file.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnikhilanmsft_0-1708319239068.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1044598i6A495D03B8B48A40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnikhilanmsft_0-1708319239068.png" alt="vnikhilanmsft_0-1708319239068.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am calling this notebook from another notebook:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnikhilanmsft_1-1708319309646.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1044599i6251EA3282A25A51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnikhilanmsft_1-1708319309646.png" alt="vnikhilanmsft_1-1708319309646.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The table got created in the lakehouse.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnikhilanmsft_2-1708319411093.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1044600i8C47D7E4860E0211/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnikhilanmsft_2-1708319411093.png" alt="vnikhilanmsft_2-1708319411093.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Hope this helps. Please let me know if you have any further questions.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 05:11:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3706794#M1389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-19T05:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3710775#M1390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/509497"&gt;@VickyDev18&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. Otherwise, will respond back with the more details and we will try to help. &lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 10:43:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3710775#M1390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-20T10:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3711024#M1391</link>
      <description>&lt;P&gt;I had tried this method but for some reason it wasn't working. However, now that I tried it again, it worked!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only simplified approach I tried was to just call the function directly without the 2nd function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So overall the approach was:-&lt;/P&gt;&lt;P&gt;1. Create a Notebook called Functions with code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd

def load_excel(source_path, source_file_name, sheet_name, destination_table):

    # Read Excel data into a Pandas DataFrame
    df = pd.read_excel(source_path + source_file_name, sheet_name=sheet_name)

    # Convert Pandas DataFrame to Spark DataFrame
    df_spark = spark.createDataFrame(df)

    # Save Spark DataFrame as a Delta table
    df_spark.write.mode("overwrite").format("delta").saveAsTable(destination_table)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a new Notebook and call the function above using the code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%run Functions

#load_excel(source_path, source_file_name, sheet_name, destination_table)
load_excel("/lakehouse/default/Files/", "Test.xlsx", "Test", "test")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 12:38:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3711024#M1391</guid>
      <dc:creator>VickyDev18</dc:creator>
      <dc:date>2024-02-20T12:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Call one notebook from another with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3711232#M1392</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/509497"&gt;@VickyDev18&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for sharing your approach here. Glad that your query got resolved. Please continue using Fabric Community for any help regarding your queries.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 13:54:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Call-one-notebook-from-another-with-parameters/m-p/3711232#M1392</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-20T13:54:40Z</dc:date>
    </item>
  </channel>
</rss>

