java.io.FileNotFoundException在本地Databricks目录上,但目录存在。

huangapple go评论54阅读模式
英文:

java.io.FileNotFoundException on local databricks directory but directory exists

问题

我正在尝试在Databricks中从一个位置复制一个目录到另一个位置。

dbutils.fs.cp("/path/to/directory", "new_path/to/directory")

在运行之前,我确认目录存在:

folders <- list.folders("/path/to/", full.names = TRUE)
print(folders)

尽管已确认存在/path/to/directory目录,但我收到以下错误:

java.io.FileNotFoundException: /path/to/directory
英文:

I am trying to copy a directory in databricks from one location to another

dbutils.fs.cp(&quot;/path/to/directory&quot;, &quot;new_path/to/directory&quot;) 

Prior to running this I confirm the directory exists:

folders &lt;- list.folders(&quot;/path/to/&quot;, full.names = TRUE) 
print(folders)

I receive this error despite /path/to/directory being confirmed as existing:

java.io.FileNotFoundException: /path/to/directory

答案1

得分: 1

如果您不指定模式,那么假定为 dbfs:,而您正试图将本地文件复制到DBFS。在使用本地文件时,您需要指定 file: 模式:

将本地文件复制到DBFS:

dbutils.fs.cp("file:/path/to/directory", "new_path/to/directory")
英文:

If you don't specify the schema, then it's assumed dbfs:, while you're trying to copy local file to DBFS. You need to specify file: schema when working with local files:

To copy local file to DBFS:

dbutils.fs.cp(&quot;file:/path/to/directory&quot;, &quot;new_path/to/directory&quot;) 

huangapple
  • 本文由 发表于 2023年7月12日 21:56:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671375.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定