Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
I have notebook code that has been exported as .py file and is formatted like this:
# Fabric notebook source
# METADATA ********************
# META {
# META "kernel_info": {
# META "name": "synapse_pyspark"
# META },
# META "dependencies": {
# META "lakehouse": {
# META "default_lakehouse": "<Lakehouse ID>",
# META "default_lakehouse_name": "Metadata",
# META "default_lakehouse_workspace_id": "<Workspace ID>"
# META }
# META }
# META }
# MARKDOWN ********************
# # Import Core Code
# CELL ********************
%run "./00 - Connections"
If I import this, it just puts all this code into a single cell in a new notebook (which is obviously not what I want). Am I doing something wrong? It would be an enormous waste of my time to reformat all of this manually. Any help is much appreciated!
Solved! Go to Solution.
Hi @Anonymous,
Thanks for your response! You’re right when exporting a Fabric notebook as a .py file and re-importing it, Fabric does not automatically split it into multiple cells. Currently, Fabric only maintains cell structure when working with .ipynb files.
If you need to frequently transfer notebooks, I recommend working with .ipynb instead of .py for seamless import/export.
I agree that Fabric should ideally recognize its own .py format properly. If this is an important workflow for you, I encourage you to share your feedback and vote for this idea on the Power BI Ideas Forum:🔗 Home, This helps the Microsoft team prioritize feature enhancements based on user demand.
If this helps, then please Accept it as a solution and dropping a "Kudos" so other members can find it more easily.
Thank you.
Hi @Anonymous,
Thank you for reaching out to the Microsoft Fabric Community.
I understand that you are facing an issue were importing a .py file into a notebook results in all the code being placed into a single cell.
You can modify the .py script to include markers or comments that can be recognized by the notebook environment to split the code into different cells automatically.
(OR)
Another approach is to import the .py file as a module in the notebook. This allows you to call functions and classes defined in the .py file without having to reformat the entire script. Here are the steps:
I hope these suggestions assist you in resolving the issue. If they do, please accept it as a solution and give a "Kudos" to help other members find it more easily.
Thank you.
Thanks for your reply!
I don't want the code as module.
I know I can modify the code to be recognized correctly as several notebook cells, but that's exactly what I hoped to avoid. Also, as far as I can tell, if I download a notebook as .py, and upload the result, it also gets put into a single cell. So Fabric doesn't even recognize its own formatting and only the .ipynb-format is correctly recognized upon import. Or am I missing something?
Hi @Anonymous,
Thanks for your response! You’re right when exporting a Fabric notebook as a .py file and re-importing it, Fabric does not automatically split it into multiple cells. Currently, Fabric only maintains cell structure when working with .ipynb files.
If you need to frequently transfer notebooks, I recommend working with .ipynb instead of .py for seamless import/export.
I agree that Fabric should ideally recognize its own .py format properly. If this is an important workflow for you, I encourage you to share your feedback and vote for this idea on the Power BI Ideas Forum:🔗 Home, This helps the Microsoft team prioritize feature enhancements based on user demand.
If this helps, then please Accept it as a solution and dropping a "Kudos" so other members can find it more easily.
Thank you.
User | Count |
---|---|
13 | |
4 | |
3 | |
3 | |
3 |
User | Count |
---|---|
8 | |
8 | |
7 | |
6 | |
5 |