[英]Python find other Python scripts in Azure Databricks folder
我正在運行 Microsoft Azure Databricks。 我想查找位於名為“tables”的文件夾中的文件。
當我在 Windows 10 計算機上的 Pycharm 中本地運行代碼時,該代碼正在運行。 但是,當我在 Databricks 中運行它時,它失敗了。
我的代碼:
import os
from os.path import isfile, join
working_dir = os.getcwd()
print(f"working dir = {working_dir}")
mypath = f"{working_dir}/tables"
files = [f for f in os.listdir(mypath) if isfile(join(mypath, f))]
for file in files:
print(f"{file}")
Windows 10 中的輸出:
C:\Users\bruker\PycharmProjects\test\venv\Scripts\python.exe C:/Users/bruker/PycharmProjects/test/test.py
working dir = C:\Users\bruker\PycharmProjects\test
1
2
數據塊錯誤:
working dir = /databricks/driver
FileNotFoundError: [Errno 2] No such file or directory: '/databricks/driver/tables'
我可以在 Microsoft Azure Databricks 中看到這些文件。 該腳本從db-adapter
運行:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.