LoginSignup
0
0

More than 1 year has passed since last update.

DatabricksにてPythonにより現在のノートブックのパスを取得する方法

Last updated at Posted at 2021-07-18

概要

dbutils.notebook.entry_point.getDbutils().notebook().getContext()によりノートブックのセッション情報が取得でき、notebook_pathの値が現在のノートブックのパスであるようです。

import json
notebook_info = json.loads(dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson())

notebook_info

image.png

本記事は、下記のStack Overflowの投稿内容を参考にしております。

現在のノートブックのパスを取得する方法

1. 下記のコードを実行

import json
notebook_info = json.loads(dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson())

current_notebook_path = notebook_info['extraContext']['notebook_path']

print(current_notebook_path)

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0