[英]expected an indented block error
I have an excel sheet having 4 rows and 5 columns.我有一个 4 行 5 列的 excel 表。 The last columns has either of the two values ie.
最后一列具有两个值之一,即。 completed and pending.
完成和待定。 All I want is to export the rows having their last column value as pending to a text file.
我想要的只是将最后一列值为待处理的行导出到文本文件。 I have tried a code but it is giving error
我试过一个代码,但它给出了错误
import xlrd
workbook=xlrd.open_workbook('C:/Users/admin/Documents/omkar.xlsx')
sh=workbook.sheet_by_name('Sheet1')
def ncols():
print sh.nrows
print sh.ncols
n=0
i=0
file=open('C:/Users/admin/Documents/om.txt','w')
for n in range(sh.nrows):
for i in range(sh.ncols):
data =str(sh.cell_value(n,i)) + " "
if sh.cell_value(n,ncols) == "pending":
print data,
file.write(data + " ")
print
file.write("\n")
import xlrd
workbook=xlrd.open_workbook('C:/Users/admin/Documents/omkar.xlsx')
sh=workbook.sheet_by_name('Sheet1')
def ncols():
print sh.nrows
print sh.ncols
n=0
i=0
file=open('C:/Users/admin/Documents/om.txt','w')
for n in range(sh.nrows):
for i in range(sh.ncols):
data =str(sh.cell_value(n,i)) + " "
if sh.cell_value(n,ncols) == "pending":
print data,
file.write(data + " ")
print
file.write("\n")
should be-应该-
import xlrd
workbook=xlrd.open_workbook('C:/Users/admin/Documents/omkar.xlsx')
sh=workbook.sheet_by_name('Sheet1')
def ncols():
print sh.nrows
print sh.ncols
file = open('C:/Users/admin/Documents/om.txt', 'w')
for n in range(sh.nrows):
if sh.cell_value(n, sh.ncols-1) == 'pending':
for i in range(sh.ncols):
data = str(sh.cell_value(n, i)) + ' '
print data,
file.write(data)
print
file.write('\n')
ncols()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.