I want to converting the text files to Excel .xls
files using python. I have used existing python script by seeing this website. but it is showing something like that more than 65656 records is not supported and.xls format not supported. Can anyone help me for this one?
Here is existing python script for converting text file to excel file:
mypath ='S://Input'
from os import listdir
from os.path import isfile, join
import xlwt
import xlrd
textfiles = [join(mypath,f) for f in listdir(mypath)
if isfile(join(mypath,f)) and '.txt' in f]
style = xlwt.XFStyle()
style.num_format_str = '#,###0.00'
for textfile in textfiles:
f = open(textfile, 'r+')
row_list = []
for row in f:
row_list.append(row.split(' '))
column_list = zip(*row_list)
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('Sheet1')
i = 0
for column in column_list:
for item in range(len(column)):
value = column[item].strip()
if is_number(value):
worksheet.write(item, i, float(value), style=style)
else:
worksheet.write(item, i, value)
i+=1
workbook.save(textfile.replace('.txt', '.xls'))