title: How to loop through Azure Datalake Store files in Azure Databricks
body: <p>I am currently listing files in <code>Azure Datalake Store gen1</code> successfully with the following command:</p>
  
  <pre><code>dbutils.fs.ls('mnt/dbfolder1/projects/clients')
  </code></pre>
  
  <p>The structure of this folder is </p>
  
  <pre><code>- 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]
  </code></pre>
  
  <p>I want to loop through those (<code>.json</code>) files in this folder and process them one by one, so that I can act on error or something else and move successfully processed file to a subfolder.</p>
  
  <p>How can I do this in <code>python</code>. I have tried </p>
  
  <pre><code>folder = dbutils.fs.ls('mnt/dbfolder1/projects/clients')
  files = [f for f in os.listdir(folder) if os.path.isfile(f)]
  </code></pre>
  
  <p>But this does not work. <code>os</code> is unknown. How can I do this within <code>Databricks</code>?</p>