如何在databricks文件系统中移动具有相同扩展名的文件? [英] How to move files of same extension in databricks files system?
问题描述
当我尝试在DBFS中使用*移动文件时,遇到文件未找到异常.这里,源目录和目标目录都在DBFS中.我在dbfs目录中有一个名为"test_sample.csv"的源文件,并且我正在笔记本单元中使用以下命令,
I am facing file not found exception when i am trying to move the file with * in DBFS. Here both source and destination directories are in DBFS. I have the source file named "test_sample.csv" available in dbfs directory and i am using the command like below from notebook cell,
dbutils.fs.mv("dbfs:/usr/krishna/sample/test*.csv", "dbfs:/user/abc/Test/Test.csv")
错误:
java.io.FileNotFoundException: dbfs:/usr/krishna/sample/test*.csv
感谢您的帮助.谢谢.
推荐答案
dbutils当前不支持通配符.您可以移动整个目录:
Wildcards are currently not supported with dbutils. You can move the whole directory:
dbutils.fs.mv("dbfs:/tmp/test", "dbfs:/tmp/test2", recurse=True)
或仅一个文件:
dbutils.fs.mv("dbfs:/tmp/test/test.csv", "dbfs:/tmp/test2/test2.csv")
如下面的注释中所述,您可以使用python来实现此通配符逻辑.另请参见以下 answer 中的一些代码示例.
As mentioned in the comments below, you can use python to implement this wildcard-logic. See also some code examples in my following answer.
这篇关于如何在databricks文件系统中移动具有相同扩展名的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!