我想将文件从 dbfs 保存或复制到我的桌面(本地)。我使用此命令但收到错误:
dbutils.fs.cp('/dbfs/username/test.txt', 'C:\Users\username\Desktop')
Error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
当我查找我的案例的 dbutils.fs.help() 时,我按照说明进行操作:
dbutils.fs provides utilities for working with FileSystems. Most methods in this package can take either a DBFS path (e.g., "/foo" or "dbfs:/foo"), or another FileSystem URI. For more info about a method, use dbutils.fs.help("methodName"). In notebooks, you can also use the %fs shorthand to access DBFS. The %fs shorthand maps straightforwardly onto dbutils calls. For example, "%fs head --maxBytes=10000 /file/path" translates into "dbutils.fs.head("/file/path", maxBytes = 10000)".
fsutils
cp(from: String, to: String, recurse: boolean = false): boolean -> Copies a file or directory, possibly across FileSystems
您需要使用 Databricks CLI 来执行此任务。
在本地计算机上安装 CLI 并运行databricks configure
进行身份验证。使用在用户设置下生成的访问令牌作为密码。
在工作区安装并配置 CLI 后,您可以将文件复制到 DBFS 或从 DBFS 复制文件,如下所示:
databricks fs cp dbfs:/path_to_file/my_file /path_to_local_file/my_file
您也可以使用简写
dbfs cp dbfs:/path_to_file /path_to_local_file
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)