title: Extracting labels from csv file for the random folders and appending
body: <p>I have a dataset where 0000 represent patient number so the dataset consists of almost 2000 patient folders, now the labels of these patients are stored in a csv file, where we have two columns one for patient and other for label. I am appending images in <code>x</code> but I have to append the exact label for the given folder in <code>y</code>, where <code>x</code> and <code>y</code> is a list. How I can extract exact label for the specific folder from csv file and append it into <code>y</code>, the following code is looping over several folders and retrieving images.<a href="https://i.stack.imgur.com/JTx1W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JTx1W.png" alt="enter image description here" /></a></p>
  <pre><code>path=os.chdir(&quot;/content/drive/MyDrive/&quot;)
  path=&quot;/content/drive/MyDrive/train&quot;
  classes=os.listdir(path)
  x=[]
  y=[]
  
  for i in classes:
    seq=os.listdir(path+u'/'+i)
    for j,k in zip(seq,classes):
      print(j) # sequence
      print(k) #patient folder
      seq2=os.listdir(path+u'/'+k+u'/'+j)
      print(seq2)
      for l in seq2:
        dc=pydicom.dcmread(path+u'/'+k+u'/'+j+u'/'+l)
        x.append(dc)
  plt.imshow(dc.pixel_array, cmap=plt.cm.bone) 
  </code></pre>