[Tutor] How to extract data from text to excel?

tee chwee liong tcl76 at hotmail.com
Fri Mar 4 09:33:44 CET 2011


bug in the previous code so the final code should be:
 
import xlwt
"""Reads robert.txt
This is the final script that writes by incrementing each row but maintain
one column"""
  
# Create workbook and worksheet 
wbk = xlwt.Workbook() 
sheet = wbk.add_sheet('python')
row = 0  # row counter
f = open('robert.txt')
for line in f:
    L = line.strip()    
    print L
    for c in L:
        print c
        sheet.write(row,0,c)
        row += 1
    
wbk.save('reformatted.data.xls')
 
_______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110304/313a57dd/attachment.html>


More information about the Tutor mailing list