title: langdetect python - to write csv of filename, directory and language
body: <p>How can I create a loop os.walk() to find all ".txt" files and create an output file .csv with three fields
  directory,filename,language ?</p>
  
  <p>I can get the file name &amp; directory by using print but i dont know how to put them in a csv.
  Also, i can get the language name using langdetect (<code>from langdetect import detect</code>,  <code>detect("001.txt"</code>) but i am stuck at looping below issue.</p>
  
  <p>Example</p>
  
  <pre class="lang-none prettyprint-override"><code>Directory  Filename Language
  /c/xx      001      en
  /c/xx/y    001      fr
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>import os
  import glob
  
  extension = '.txt'
  os.chdir("/Desktop/Language_test")
  result = [i for i in glob.glob('*.{}'.format(extension))]
  print(result)
  
  path=os.getcwd()
  extension = '.txt'
  for root, dirs_list, files_list in os.walk(path):
      for file_name in files_list:
          if os.path.splitext(file_name)[-1] == extension:
              file_name_path = os.path.join(root, file_name)
              print(file_name)
              print(file_name_path)   # This is the full path of 
  </code></pre>
  
  <p>the filter file</p>