title: Read in multiple txt documents and output to excel with openpyxl
body: <p>I am trying to read in multiple txt files across across an indefinite amount of subdirectories. In the txt files is a peice of text on a new line, which is actually formatted like a network share "\uisdff\uiefn"</p>
  
  <p>I am trying to get the name of the top level folder, and then for each row in the subsequent text file, write each line individually into an excel sheet, alongside the folder name and the date. </p>
  
  <p>This is what I have currently - </p>
  
  <pre><code>import openpyxl
  import subprocess
  import datetime
  import os, time
  
  directory='.'
  
  path='Test.xlsx'
  
  
  wb_obj = openpyxl.load_workbook(path)
  
  sheet_obj =  wb_obj["Sheet1"]
  
  
  cell_obj = sheet_obj.cell(row = 1, column = 1) 
  
  m_row = 2000
  
  
  
  
  subfolders = [f.name for f in os.scandir(directory) if f.is_dir() ]  
  for i in subfolders:
      subdirectory= directory+'\\'+ i
      for file in os.listdir(subdirectory):
          filename= subdirectory+"\\"+file
          file1= open(filename, "r")
          for i in range(1, m_row + 1): 
              for items in file1.readlines():
  
  
                  unc_obj = sheet_obj.cell(row = i, column = 1)
                  fol_obj = sheet_obj.cell(row = i, column = 2)
                  date_obj = sheet_obj.cell(row = i, column = 3)
  
  
  
                  unc_obj.value = items
                  fol_obj.value = "TEST"
                  date_obj = date
  
  
  
      wb_obj.save(writepath)                        
  </code></pre>
  
  <p>Im very new to python, so some pointers would be awesome! No matter what I try, its either writing the last line in the last file, write to line 2000(there is 2000 lines in total across all documents, but this will vary), or its only writing in a1. </p>
  
  <p>My text files look like the following </p>
  
  <pre><code>\\hbi\jinkn
  \\test\jnn
  </code></pre>
  
  <hr>
  
  <pre><code>    test = []
      for items in file1.readlines():
  
          thisitem = items.replace(r'"\\', r"\\")
          more = thisitem.replace("  ,is an open share\"", "")
  
  
          unc_obj = more
          print(unc_obj)
          MKT_obj = "TEST"
          date_obj= str(datetime.datetime.now())
          row = [unc_obj.rstrip(), MKT_obj,date_obj]
          test.append(row)
  
      sheet_obj.append(test)                
  
  
      wb_obj.save(writepath)       
  </code></pre>
  
  <p>I am now looking at using sheet.append. But getting an error in which it cant convert values to excel. </p>