我目前正在使用Python和PyQt创建一个Excel过滤工具。目标是能够过滤出学生的平均成绩,并根据他们的成绩和平均成绩的截止值输出一定的结果。在
当我在我的IDE PyCharm上运行程序时,程序运行过滤并运行到完成,我能够输出过滤结果,但是在这个过程中,我收到了错误“too much output to process”。我试图用Cx_freeze在IDE外部构建程序,当我运行exe版本时,程序只会通过过滤器运行几行excel文件,然后停止运行。我相信这是由于我之前的错误,我会在IDE中看到excel文件中有太多的文本行。在
我的excel文件有大约6000行数据和16列。在
这是代码的一部分:
def filterCommand(self):
global workbook2
wb = xlrd.open_workbook(defaultName)
sheet = wb.sheet_by_index(0)
workbook2 = xlwt.Workbook()
worksheet2 = workbook2.add_sheet('Test')
styles = xlwt.easyxf('pattern: pattern solid, fore_colour yellow')
#Then get values of each column. Excuse first item which is header
term = sheet.col_values(0)[1:]
ids = sheet.col_values(1)[1:]
fnames = sheet.col_values(3)[1:]
lnames = sheet.col_values(2)[1:]
gender = sheet.col_values(4)[1:]
zero = sheet.col_values(5)[1:]
acadgroup = sheet.col_values(6)[1:]
acadprog = sheet.col_values(7)[1:]
status = sheet.col_values(9)[1:]
strtlevel = sheet.col_values(10)[1:]
acaplan = sheet.col_values(8)[1:]
credits = sheet.col_values(12)[1:]
GPA = sheet.col_values(11)[1:]
fiucredits = sheet.col_values(13)[1:]
transferc = sheet.col_values(14)[1:]
takeprgrs = sheet.col_values(15)[1:]
type1 = sheet.col_values(16)[1:]
email1 = sheet.col_values(17)[1:]
type2 = sheet.col_values(18)[1:]
email2 = sheet.col_values(19)[1:]
phone = sheet.col_values(20)[1:]
ethnicgroup = sheet.col_values(21)[1:]
firstgen = sheet.col_values(22)[1:]
newrow = sheet.nrows
header = []
for i in range(0, 1):
rowheader = sheet.row_values(i)
header.extend(rowheader)
print header[0]
for ind, key in enumerate(header):
worksheet2.write(0, ind, key)
row = 1
for index, row_data in enumerate(credits):
grade_level = row_data
gpa_level = GPA[index]
# row_data[index] = float(credits)
# worksheet2.write_column(row, 0, row_data)
# Check for rows that match the filter.
print gpa_level
print grade_level
if grade_level >= 90.0:
print fnames[index] + '\t' + lnames[index] + '\t' + ": Senior"
if gpa_level >= 3.2:
#Do Filtering
print '\t' + "Allowed"
row += 1
pass
else:
print '\t' + "not allowed"
# worksheet2.set_row(row, None, None, {'hidden': True})
elif (grade_level <= 89.0 and grade_level >= 60.0):
print fnames[index] + '\t' + lnames[index] + '\t' + ": Junior"
if gpa_level >= 3.0:
#Do Filtering
print '\t' + "Allowed"
row += 1
pass
else:
print '\t' + "not allowed"
# worksheet2.set_row(row, options={'hidden': True})
elif (grade_level <= 59.0 and grade_level >= 30.0):
print fnames[index] + '\t' + lnames[index] + '\t' + ": Sophomore"
if gpa_level >= 2.7:
#Do Filtering
print '\t' + "Allowed"
row += 1
pass
else:
print '\t' + "not allowed"
# worksheet2.set_row(row, options={'hidden': True})
elif grade_level < 30.000:
print fnames[index] + '\t' + lnames[index] + '\t' + ": Freshmen"
if gpa_level >= 2.5:
#Do Filtering
print '\t' + "Allowed"
row += 1
pass
else:
print '\t' + "not allowed"
这是我的excel工作表:
我怎么能着手解决这个问题,因为我不知道为什么它在IDE中工作,而在.exe中不起作用
抱歉。作为回报,你听说过吗ISO:OSI堆栈? 例如:ISO:OSI stack。在
很可能可用的代码页确实发生了变化。你会得到一个由这些问题引起的错误。在IDE中,堆栈被控制。在运行环境中则不然。在
本文可能已经解决了您的问题: Python socket programming and ISO-OSI model
其他类型的问题可能是RTF-8。如果解释不正确,那么电子表格中的Excel控制序列就如同病毒一样,或者仅仅是溢出的原因。在
Export Pandas data frame with text column containg utf-8 text and URLs to Excel
Python程序员的一个非常古老的规则是aviod原生微软格式。最好使用直接与RTF-8等编解码器相关的文本基格式。由于微软格式policies的变化,这种情况最近几乎没有改变。在
希望有帮助。在
相关问题 更多 >
编程相关推荐