【问题标题】:Program completes but I receive this warning: "too much output to process"程序完成但我收到此警告:“要处理的输出过多”
【发布时间】:2015-11-23 15:57:47
【问题描述】:

我目前正在使用 Python 和 PyQt 创建 Excel 过滤工具。目标是能够过滤掉学生的GPA,并根据他们的年级和GPA的截止值输出一定的结果。

当我在我的 IDE PyCharm 上运行程序时,程序运行过滤并运行到完成,我能够输出过滤结果,但是在此过程中我收到错误“输出太多无法处理”。我尝试使用 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 中无效

【问题讨论】:

    标签: python excel process


    【解决方案1】:

    对不起。一个问题作为回报:你听说过 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 程序员的一条非常古老的规则是避免使用原生 Microsoft 格式。您最好使用与 RTF-8 等 CODEC 直接相关的文本基本格式。由于 mircosoft 格式政策的变化,这种情况最近才几乎没有改变。

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 2019-04-01
      • 2018-05-03
      • 1970-01-01
      相关资源
      最近更新 更多