【发布时间】:2021-05-24 20:24:52
【问题描述】:
我正在使用下面的 Python 代码从 Databricks Filestore 下载 csv 文件。通常,保存在 Filestore 中的文件可以通过浏览器下载。
当我在浏览器中直接输入文件的 url 时,文件下载正常。但是当我尝试通过下面的代码执行相同操作时,下载文件的内容不是 csv,而是一些 html 代码 - 见下文。
这是我的 Python 代码:
def download_from_dbfs_filestore(file):
url ="https://databricks-hot-url/files/{0}".format(file)
req = requests.get(url)
req_content = req.content
my_file = open(file,'wb')
my_file.write(req_content)
my_file.close()
这里是html。它似乎是在引用登录页面,但不确定从这里做什么:
<!doctype html><html><head><meta charset="utf-8"/>
<meta http-equiv="Content-Language" content="en"/>
<title>Databricks - Sign In</title><meta name="viewport" content="width=960"/>
<link rel="icon" type="image/png" href="/favicon.ico"/>
<meta http-equiv="content-type" content="text/html; charset=UTF8"/><link rel="icon" href="favicon.ico">
</head><body class="light-mode"><uses-legacy-bootstrap><div id="login-page">
</div></uses-legacy-bootstrap><script src="login/login.xxxxx.js"></script>
</body>
</html>
【问题讨论】:
-
您的意思是代码在 Databricks 笔记本之外执行?您使用的是社区版还是“普通”Databricks?
标签: databricks azure-databricks