title: Excluding files of a certain size
body: <p>I'm trying to generate a .csv file that lists all .txt file in a sub-directory but can exclude a .txt file of a certain size.</p>
  
  <p>Without an if statement around file size, I can successfully generate the .csv file list that has the full paths to the .txt files (1105 files total)</p>
  
  <pre><code>import os
  import csv
  import os.path
  mtn_path = "TEXT_FILE_PATH\\"
  a = open(mtn_path + "output.csv", 'w+', newline='')
  num_files = 0
  for path, dirnames, filenames in os.walk(mtn_path):
      for filename in [f for f in filenames if f.endswith(".txt")]:
  #       if os.stat(filename).st_size &gt; 20000:
              f = os.path.join(path, filename)
              a.write(str(f) + os.linesep)
              num_files = num_files + 1
  )
  #
  print("The total number of text files found was " + str(num_files))
  </code></pre>
  
  <p>When I include the if os.stat line, I get the error:</p>
  
  <p>FileNotFoundError: [WinError 2] The system cannot find the file specified: 'INT_NR_H1000Cu_000.mtn_001.txt'</p>
  
  <p>That particular .txt file is the first one listed in the csv file of the working code.</p>