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

tee chwee liong tcl76 at hotmail.com
Fri Mar 4 01:44:30 CET 2011

> What does this comment mean? You don't have any commas in the file 
> "robert.txt", and you don't actually do anything with or to commas in 
> your code. I think that comment is false.
> > L = line.strip() 
> > sheet.write(row,0,L) 
> Here you write the entire contents of the file into one cell. You need 
> to iterate over L:
> for c in L:
> sheet.write(row, 0, c)
> row += 1

hi steven,
ok i get what you meant. there are no pattern to split the entire contents in the robert.txt. 
is the content still needed to be splitted? 
L = line.split() will result in one long string.
could you pls explain what is c? how do i modify the c in the code? pls advise. tq
for line in f:
#for c in L:        
    L = line.split()    
    print L
    row += 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110304/08b632bc/attachment.html>

More information about the Tutor mailing list