I have 100 txt files in a folder (named as pos). I would like to copy all the file contents and paste them as rows in an excel file. I found some codes from stackoverflow, but they are not working. Please help me.
import xlwt
import os
import glob
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('data')
path= 'C:\tweet\pos'
row = 0
for files in os.walk(path):
... for file in files:
... if fnmatch(file, '*.txt'):
... L = open(os.path.join( file), "r").read()
... sheet.write(row,5,L)
... row += 1
...
wbk.save('read_all_txt_in_folders.xls')