to print the python script output in excel
<p>i want to print the output of python script in excelfile. i tried this code  but it reads each line from the selected input file and then writes it to a new excel file called output.xls? thank you</p>

<pre><code> import xlwt
 from Tkinter import *            
 from tkFileDialog   import askopenfilename      

 def callback():
     filename = askopenfilename()
     wb = xlwt.Workbook()
     ws0 = wb.add_sheet('Sheet1')

     with open(filename, 'r') as f:
         for i, line in enumerate(f):
             ws0.write(i, 0, line.strip())
     wb.save('output.xls')

 errmsg = 'Error!'
 a = Button(text='click me', command=callback)
 a.pack()
 mainloop()
</code></pre>
