Accessing a Utility File inside a Notebook
Steps to access a Utility script inside a Notebook.
Accessing Utility Files Inside a Notebook
The BDB Data Science Lab allows users to access and execute reusable utility scripts directly within notebook environments. These utility scripts typically contain helper functions—such as data generators, preprocessors, or reusable analysis logic—that can be imported and used across multiple projects.
There are two ways to access a utility file inside a Notebook:
Using the Code
Using the Copy Path Option
Accessing the Utility Script through Code
Navigate to the Utils Folder
Open the project workspace within the Data Science Lab.
Locate the Utils folder under the selected project.
Identify the required utility script
Example,
dataframe_generator.py. This file likely defines a reusable function namedgenerate_dataframe()that creates a sample DataFrame.
Open a Notebook
Navigate to the Repo folder under the same project.
Open an existing notebook or create a new one.
The notebook interface will appear on the right side of the page.
Insert a Code Cell
Inside the notebook, add a new code cell where you will write the import and execution statements.
Execute the Import and Function Call
Run the following code in the code cell:
from dataframe_generator import *
generate_dataframe()Explanation:
The line
from dataframe_generator import *imports all available functions from thedataframe_generator.pyscript. This makes the functions defined in that utility script directly accessible inside the notebook environment.The
generate_dataframe()function is then called.This function creates and returns a sample pandas DataFrame.
Execution Details
Once the code cell is executed:
The notebook cell executes successfully in 0.08 seconds (indicated by the green status icon).
The kernel status shows as Running, confirming an active Python environment.
CPU and RAM usage are displayed at the top-right, providing resource utilization information.
Access a Utility Script through Copy Path
The Copy Path feature in the BDB Data Science Lab allows you to execute a utility script directly inside a Notebook by referencing its full system path. This is helpful when you want to run or reuse logic from a script without importing it as a module.
The steps below explain how to use this feature to run the dataframe_generator.py utility file.
Navigate to the Utils Folder
Locate the Utils folder under the selected project.
Identify the required utility script—for example,
dataframe_generator.py. This file likely defines a reusable function namedgenerate_dataframe()that creates a sample DataFrame.Click the Ellipsis menu (⋮) next to the utility script.
Load and Execute the Script
Use Python’s file handling and
exec()to read and run the utility script:
with open(filepath, "r") as file:
code = file.read()
# Execute the code from the file
exec(code)This executes everything inside
dataframe_generator.py, including functions such asgenerate_dataframe().
Last updated



