[Tutor] Traversing Excel Columns
Kent Johnson
kent37 at tds.net
Tue Sep 12 00:28:58 CEST 2006
Chris Hengge wrote:
> This is what I have, but it requires me to know the end of the column
> I'm working with, which changes.
>
> try:#Loop through the rows from 6 -> 25
> for row in range(6, 25):
> #Write each row, increment 1+row in column 5
> print >> file, "(%d) => %s" % (row, xlSht.Cells (1+row, 5).Value)
>
> I'm looking for something more like
> try:#Loop until rows are null
> while row in xlwksht != null
> #Write each row, incriment 1+row in column 5
> print >> file, "'" + %s + "',", % (xlSht.Cells(1+row,5).Value)
What is xlSht? Are you using COM, or xlrd, or pycelerator, or?? to read
the spreadsheet? It probably has a way to find out the last row, or if
the cell has data...
Kent
More information about the Tutor
mailing list