我正在使用 dbutils.fs.cp(sourcefilepath,destinationfilepath) 查询将文件从一个位置从 azure 存储复制到另一个位置。我的源文件路径是 /mnt/testing/StudentA/Test.csv ,目标文件路径是 / mnt/Testing_1/。在这种情况下,dbutils 正在运行,但在目标中它会创建一个文件夹名称为 (StudentA) 的文件,还会创建一个名为 StudentA 的文件夹并放置 Test.csv。
我同意@Chen Hirsh。
sourcefilepath="/mnt/testing/StudentA/mycsv2.csv"
destinationfilepath="/mnt/testing1"
dbutils.fs.cp(sourcefilepath,destinationfilepath)
此代码不会复制文件夹,它只会在目标位置创建一个新的
mycsv2.csv
文件。
仅当您在代码中使用递归
True
时,才会像下面那样复制您问题中提到的文件夹副本。
sourcefilepath="/mnt/testing"
destinationfilepath="/mnt/testing1/samp1/"
dbutils.fs.cp(sourcefilepath,destinationfilepath,True)
因此,重新检查您的代码和文件路径。如果您对源文件没有任何用法,您也可以尝试
dbutils.fs.mv
作为解决方法。