title: Listdir not finding all files inside loop
body: <p>I have a code that do some transformation in some files, for a range of years and quarterly/semiannually. Here is the code:</p>
  <pre><code>year = ['2017', '2018', '2019', '2020']
  for y in year:
      onlyfiles1 = [file for file in listdir('prev_dir/'+y+'/detailed') if isfile(join('prev_dir/'+y+'/detailed', file))]
      onlyfiles2 = [file for file in listdir('prev_dir/'+y+'/old') if isfile(join('prev_dir/'+y+'/old', file))]  
      if len(onlyfiles2) &lt; len(onlyfiles1):
          onlyfiles2.append('')
      for i, j in zip(onlyfiles1, onlyfiles2):
          print(i, j)
          function_transform(i, j, 'prev_dir/final'+i, y)
  </code></pre>
  <p>It was working correctly last quarter, but now that in 2020 has a new file it won't read the last file.</p>
  <p>If I run only to check if the files are readable:</p>
  <pre><code>[file for file in listdir('prev_dir/'+y+'/detailed') if isfile(join('prev_dir/'+y+'/detailed', file))]
  Out: ['1_qua_2020.xlsx', '2_qua_2020.xlsx']
  </code></pre>
  <p>All years, except 2020, has a file in 'old' folder that is used by one of the functions inside function_transform. When I run the code it iterate through the years and folders correctly, except for the last file '2_qua_2020.xlsx', as you can see below:</p>
  <pre><code>1_sem_2017.xlsx 1o_sem_2017.xlsx        #files in 'detailed' and 'old' folder
  data_transf/final_1_sem_2017.xlsx       #name of saved file
  392780                                  #len df
  2_sem_2017.xlsx 2o_sem_2017.xlsx
  data_transf/final_2_sem_2017.xlsx 
  340522
  1_sem_2018.xlsx 1o_sem_2018.xlsx
  data_transf/final_1_sem_2018.xlsx 
  380199
  2_sem_2018.xlsx 2o_sem_2018.xlsx
  data_transf/final_2_sem_2018.xlsx 
  370914
  1_sem_2019.xlsx 1_sem_19_at.xlsx
  data_transf/final_1_sem_2019.xlsx 
  595040
  2_sem_2019.xlsx 
  data_transf/final_2_sem_2019.xlsx 
  540177
  1_qua_2020.xlsx 
  data_transf/final_1_qua_2020.xlsx 
  350119
  </code></pre>
  <p>I run some tests and if 'detailed' folder has more than 2 files than 'old' folder it will not work. Independently if I use 'if' statement from the code. Hope you guys could enlighten me what I could be doing wrong.</p>
  <p>*Files in 'detailed' folder I get from another code from the database.</p>
  <p>Thanks!</p>