如何在Azure Databricks中循环浏览Azure Datalake存储文件

STO*_*ORM 4 python azure azure-data-lake databricks

我目前正在Azure Datalake Store gen1使用以下命令成功列出文件:

dbutils.fs.ls('mnt/dbfolder1/projects/clients')
Run Code Online (Sandbox Code Playgroud)

该文件夹的结构是

- client_comp_automotive_1.json [File]
- client_comp_automotive_2.json [File]
- client_comp_automotive_3.json [File]
- client_comp_automotive_4.json [File]
- PROCESSED [Folder]
Run Code Online (Sandbox Code Playgroud)

我想遍历.json该文件夹中的那些()文件,并一一处理它们,以便我可以对错误或其他内容采取行动,并将成功处理的文件移至子文件夹。

我怎样才能做到这一点python。我试过了

folder = dbutils.fs.ls('mnt/dbfolder1/projects/clients')
files = [f for f in os.listdir(folder) if os.path.isfile(f)]
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。os未知。我该如何在内部执行此操作Databricks

STO*_*ORM 7

即使我搜索了两天,答案也很简单:

files = dbutils.fs.ls('mnt/dbfolder1/projects/clients')

for fi in files: 
  print(fi.path)
Run Code Online (Sandbox Code Playgroud)