我们如何在 dbfs/filestore 上保存或上传 .py 文件
How can we save or upload .py file on dbfs/filestore
我们本地需要 stored/saved dbfs 上的文件存储路径上的 .py 文件很少。我怎样才能做到这一点?
尝试使用 dbUtils.fs
模块复制操作。
我试过下面的代码但没有用,我知道我的源路径有问题。或者有更好的方法吗?请指教
'''
dbUtils.fs.cp ("c:\file.py", "dbfs/filestore/file.py")
'''
听起来你想将本地文件复制到Azure Databricks 服务器的dbfs 路径。但由于Azure Databricks Notebook基于浏览器的交互界面,无法通过云端编程直接操作本地文件。
所以您可以尝试以下解决方案。
正如@Jon在评论中所说,大家可以关注官方文档Databricks CLI
to install the databricks CLI via Python tool command pip install databricks-cli
on local and then copy a file to dbfs.
按照官方文档Accessing Data
通过Drop files into or browse to files in the Import & Explore Data box on the landing page
导入数据,但也推荐使用CLI,如下图
将您指定的文件上传到Azure Blob Storage,然后按照官方文档Data sources / Azure Blob Storage
进行操作,包括dbutils.fs.cp
.
希望对您有所帮助。
我们本地需要 stored/saved dbfs 上的文件存储路径上的 .py 文件很少。我怎样才能做到这一点?
尝试使用 dbUtils.fs
模块复制操作。
我试过下面的代码但没有用,我知道我的源路径有问题。或者有更好的方法吗?请指教
'''
dbUtils.fs.cp ("c:\file.py", "dbfs/filestore/file.py")
'''
听起来你想将本地文件复制到Azure Databricks 服务器的dbfs 路径。但由于Azure Databricks Notebook基于浏览器的交互界面,无法通过云端编程直接操作本地文件。
所以您可以尝试以下解决方案。
正如@Jon在评论中所说,大家可以关注官方文档
Databricks CLI
to install the databricks CLI via Python tool commandpip install databricks-cli
on local and then copy a file to dbfs.按照官方文档
Accessing Data
通过Drop files into or browse to files in the Import & Explore Data box on the landing page
导入数据,但也推荐使用CLI,如下图将您指定的文件上传到Azure Blob Storage,然后按照官方文档
Data sources / Azure Blob Storage
进行操作,包括dbutils.fs.cp
.
希望对您有所帮助。