title: opening text files in different folders and write to a csv cell
body: <p>I am trying to get texts from different folders and write each text into a single cell in a CSV format with its file name (*.txt)</p>
  <pre><code>import os
  folders = os.listdir(&quot;/Users/hilo/Documents/digitization/ReleasedDataset_mp3&quot;)
  folders
  
  import  glob, csv
  
  
  
  </code></pre>
  <p>here I tried to get the list of folder names, and they are like:</p>
  <pre><code>['Becton Dickinson_20170803',
   'CIGNA Corp._20170202',
   'The Bank of New York Mellon Corp._20170720',
   'JPMorgan Chase &amp; Co._20170714']
  </code></pre>
  <p>here I try to apply a loop to open and extract all text from each *txt file and write all text into a cell in the csv file with the key( *)</p>
  <pre><code>for i in folders:
      files=glob.glob(&quot;/Users/hilo/Documents/digitization/ReleasedDataset_mp3/i/*.txt&quot;)
  with open('writeData.csv', mode='w') as new_file:
    writer = csv.writer(new_file, delimiter=',', quotechar='&quot;', quoting=csv.QUOTE_MINIMAL)
    for filename in files:
  
      # Take all sentences from a given file
      file = open(filename, 'rt')
      text = file.read()
      file.close()
  
      for text in text:
        writer.writerow((filename, text))
  </code></pre>
  <p>this keeps producing an empty CSV. does anyone have a suggestion to solve the issue in the code?</p>