I am reading a text file a.txt which has so many columns and i need the data in 5 colu开发者_Python百科mns. I fetched it by reading and get data of 5 columns,but my question is how can I import these 5 columns data into one excel file having same column as in text file.
Here is an example explaining how to generate an excel file with the xlwt python lib.
Using win32 would be ok but i personnaly prefer to use xlwt because it doesn't require excel to be installed on the machine.
import xlwt
wb = xlwt.Workbook()
ws = wb.add_sheet("My sheet")
for line in xrange(10):
for col in xrange(5):
ws.write(line, col, line*10+col)
wb.save('myfile.xls')
I hope it helps
精彩评论