title: Trying to write filename to csv
body: <p>My code determines if the contents of the file returns <code>True</code> or <code>False</code> and output the results to a .csv. </p>
  
  <p>I would like to write the filename also to the csv in the same row. </p>
  
  <p><strong>Error message</strong></p>
  
  <pre class="lang-none prettyprint-override"><code>for i in range(vt_result_file):
  NameError: name 'vt_result_file' is not defined
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import os
  import json
  import csv
  
  path=r'./output/'
  csvpath='C:/Users/xxx/Documents/csvtest'
  file_n = 'file.csv'
  
  def vt_result_check(path):
      vt_result = False
      for filename in os.listdir(path):
          with open(path + filename, 'r') as vt_result_file:
              vt_data = json.load(vt_result_file)
  
          # Look for any positive detected referrer samples
          # Look for any positive detected communicating samples
          # Look for any positive detected downloaded samples
          # Look for any positive detected URLs
          sample_types = ('detected_referrer_samples', 'detected_communicating_samples',
                          'detected_downloaded_samples', 'detected_urls')
          vt_result |= any(sample['positives'] &gt; 0 for sample_type in sample_types
                                                   for sample in vt_data.get(sample_type, []))
  
          # Look for a Dr. Web category of known infection source
          vt_result |= vt_data.get('Dr.Web category') == "known infection source"
  
          # Look for a Forecepoint ThreatSeeker category of elevated exposure
          # Look for a Forecepoint ThreatSeeker category of phishing and other frauds
          # Look for a Forecepoint ThreatSeeker category of suspicious content
          threats = ("elevated exposure", "phishing and other frauds", "suspicious content")
          vt_result |= vt_data.get('Forcepoint ThreatSeeker category') in threats
  
      return str(vt_result)
  
  
  if __name__ == '__main__':
      with open(file_n, 'w') as output:
          for i in range(vt_result_file):
              output.write(vt_result_file, vt_result_check(path))
  </code></pre>