title: How to create a csv file with labels from a list of images
body: <p>i have multiple folders in a directory and in each of the folder are hundred of images(.jpg).</p>
  
  <p>Now i try to create a csv file, which includes the name of the image, a comma and then the label of it. </p>
  
  <p>So my folders are </p>
  
  <p>dog
  cat
  mouse
  elephant </p>
  
  <p>and in these are images titled dog1.jpg, dog2.jpg, ... cat1.jpg, and so on. </p>
  
  <p>I have already tried to list all the names of the pictures with the following code:</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  
  path = '/content../'
  
  files = []
  for  r, d, f in os.walk(path):
      for file in f:
          if '.jpg' in file:
            print(file)
  </code></pre>
  
  <p>This prints me the list of my images. 
  My thoughts are that i create something like </p>
  
  <pre class="lang-py prettyprint-override"><code>import csv 
  
  # csv file name 
  with open('test.csv')
  category []
  if filename == 'dog' then append 0 
  if filename == 'cat' then append 1 ... 
  </code></pre>
  
  <p>But I am getting nowhere. </p>
  
  <p>At the end the csv file should look like:</p>
  
  <pre class="lang-py prettyprint-override"><code>dog1.jpg,0
  dog2.jpg,0
  cat1.jpg,1
  mouse2.jpg,2
  elepant.jpg,3
  </code></pre>
  
  <p>I hope you can help me, Thank you very much!</p>