hi,
 
i found a module called xlwt (http://www.python-excel.org/) that can write to 
Excel. i want the code to read from a file (robert.txt) and then write to excel 
in a column. for eg:
cell col0, row0 = 0
cell col0, row1 = 0
cell col0, row2 = 0
cell col0, row3 = 1
cell col0, row4 = 0
cell col0, row5 = 1

however, it seems that the output from this code is that it only writes to one 
cell in the excel. Pls advise how to modify the code. Pls advise if there are 
alternative way for python to do this task? tq

import xlwt
# Create workbook and worksheet 
wbk = xlwt.Workbook() 
sheet = wbk.add_sheet('python')
row = 0  # row counter
f = open('robert.txt')
for line in f: 
    # separate fields by commas 
    L = line.strip()    
    sheet.write(row,0,L)    
    row += 1
  
wbk.save('reformatted.data.xls')

 
thanks
tcl
                                          
01010100011111011111101111111011101100110011001100111100000000001100110001000111111000000000001100000000000000000111000000000000101101111101101111000000000011000001000110001000110001000110001000110001000110001000110000010100100110010110011001010101010101010101010100000000000000000011111000110000100001000000000001110111111101000100000000000000011100111111111110111111111111111111111010111111111111111111101101111111111100011101001110011111111010000000100000000000000000000000000000000000000000000000000111110111111111111011101111101111101111111111100111100001110111111111
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to