当前位置: 首页>>代码示例>>Python>>正文


Python xlrd.XL_CELL_EMPTY属性代码示例

本文整理汇总了Python中xlrd.XL_CELL_EMPTY属性的典型用法代码示例。如果您正苦于以下问题:Python xlrd.XL_CELL_EMPTY属性的具体用法?Python xlrd.XL_CELL_EMPTY怎么用?Python xlrd.XL_CELL_EMPTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在xlrd的用法示例。


在下文中一共展示了xlrd.XL_CELL_EMPTY属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_has_non_empty_cells

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def test_has_non_empty_cells():
    row = []
    reader = XLSReader()
    assert has_non_empty_cells(reader, []) is False
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_BLANK, ''))
    assert has_non_empty_cells(reader, row) is False
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'x1'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'input with space'))
    assert has_non_empty_cells(reader, row) is True
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 10))
    assert has_non_empty_cells(reader, row) is True
    row = []
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 10))
    assert has_non_empty_cells(reader, row) is True 
开发者ID:araith,项目名称:pyDEA,代码行数:18,代码来源:test_read_data_from_xls.py

示例2: test_extract_coefficients

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def test_extract_coefficients():
    row = []
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'dmu1'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 10))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 25))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 45))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 0))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 7.9))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    reader = XLSReader()
    (dmu, coefficients, dmu_name) = extract_coefficients(
        reader, row, [4, 5, 7, 8, 10])
    assert dmu == 'dmu1'
    assert coefficients == [10, 25, 45, 0, 7.9] 
开发者ID:araith,项目名称:pyDEA,代码行数:22,代码来源:test_read_data_from_xls.py

示例3: test_extract_coefficients_with_numeric_dmu

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def test_extract_coefficients_with_numeric_dmu():
    row = []
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 0))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 10))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 25))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 45))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 0))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 7.9))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u' aha '))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    reader = XLSReader()
    (dmu, coefficients, dmu_name) = extract_coefficients(
        reader, row, [3, 4, 5, 6, 7, 8, 9])
    assert dmu == 0
    assert coefficients == [10, 25, 45, 0, 7.9, '', 'aha'] 
开发者ID:araith,项目名称:pyDEA,代码行数:20,代码来源:test_read_data_from_xls.py

示例4: cell_display

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def cell_display(cell, datemode=0, encoding='ascii'):
    cty = cell.ctype
    if cty == xlrd.XL_CELL_EMPTY:
        return 'undefined'
    if cty == xlrd.XL_CELL_BLANK:
        return 'blank'
    if cty == xlrd.XL_CELL_NUMBER:
        return 'number (%.4f)' % cell.value
    if cty == xlrd.XL_CELL_DATE:
        try:
            return "date (%04d-%02d-%02d %02d:%02d:%02d)" \
                % xlrd.xldate_as_tuple(cell.value, datemode)
        except xlrd.xldate.XLDateError:
            return "date? (%.6f)" % cell.value
    if cty == xlrd.XL_CELL_TEXT:
        return "text (%s)" % cell.value.encode(encoding, 'replace')
    if cty == xlrd.XL_CELL_ERROR:
        if cell.value in xlrd.error_text_from_code:
            return "error (%s)" % xlrd.error_text_from_code[cell.value]
        return "unknown error code (%r)" % cell.value
    if cty == xlrd.XL_CELL_BOOLEAN:
        return "logical (%s)" % ['FALSE', 'TRUE'][cell.value]
    raise Exception("Unknown Cell.ctype: %r" % cty) 
开发者ID:Scemoon,项目名称:lpts,代码行数:25,代码来源:display.py

示例5: __is_header_row

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def __is_header_row(self, row_idx):
        try:
            from excelrd import XL_CELL_EMPTY
        except ImportError:
            from xlrd import XL_CELL_EMPTY

        return XL_CELL_EMPTY not in self._worksheet.row_types(
            row_idx, self._start_col_idx, self._end_col_idx + 1
        ) 
开发者ID:thombashi,项目名称:pytablereader,代码行数:11,代码来源:excelloader.py

示例6: __is_empty_cell_types

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def __is_empty_cell_types(cell_types):
        try:
            from excelrd import XL_CELL_EMPTY
        except ImportError:
            from xlrd import XL_CELL_EMPTY

        return all([cell_type == XL_CELL_EMPTY for cell_type in cell_types]) 
开发者ID:thombashi,项目名称:pytablereader,代码行数:9,代码来源:excelloader.py

示例7: test_extract_categories

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def test_extract_categories():
    row = []
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'x1'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'x2'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'input with space'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'output starts with space'))
    reader = XLSReader()
    categories, indexes = extract_categories(reader, row)
    assert categories == ['x1', 'x2',
                          'input with space', 'output starts with space'] 
开发者ID:araith,项目名称:pyDEA,代码行数:15,代码来源:test_read_data_from_xls.py

示例8: test_extract_numeric_categories

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def test_extract_numeric_categories():
    row = []
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 5))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, 15))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_NUMBER, -100))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_TEXT, u'x1'))
    row.append(xlrd.sheet.Cell(xlrd.XL_CELL_EMPTY, ''))
    reader = XLSReader()
    categories, indexes = extract_categories(reader, row)
    assert categories == [5, 15, -100, 'x1'] 
开发者ID:araith,项目名称:pyDEA,代码行数:16,代码来源:test_read_data_from_xls.py

示例9: parse_row

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def parse_row(row, fieldnames):
    return {f: r.value for f, r in zip(fieldnames, row[0:SERVICES_COLUMN])
            if r.ctype != XL_CELL_EMPTY} 
开发者ID:Telecominfraproject,项目名称:oopt-gnpy,代码行数:5,代码来源:service_sheet.py

示例10: show_name_object

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def show_name_object(book, nobj, show_contents=0, f=sys.stdout):
    print("\nName: %s, scope: %s (%s)" \
        % (REPR(nobj.name), REPR(nobj.scope), scope_as_string(book, nobj.scope)), file=f)
    res = nobj.result
    print("Formula eval result: %s" % REPR(res), file=f)
    if res is None:
        return
    # result should be an instance of the Operand class
    kind = res.kind
    value = res.value
    if kind >= 0:
        # A scalar, or unknown ... you've seen all there is to see.
        pass
    elif kind == xlrd.oREL:
        # A list of Ref3D objects representing *relative* ranges
        for i in range(len(value)):
            ref3d = value[i]
            print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3drel(book, ref3d))), file=f)
    elif kind == xlrd.oREF:
        # A list of Ref3D objects
        for i in range(len(value)):
            ref3d = value[i]
            print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3d(book, ref3d))), file=f)
            if not show_contents:
                continue
            datemode = book.datemode
            for shx in range(ref3d.shtxlo, ref3d.shtxhi):
                sh = book.sheet_by_index(shx)
                print("   Sheet #%d (%s)" % (shx, sh.name), file=f)
                rowlim = min(ref3d.rowxhi, sh.nrows)
                collim = min(ref3d.colxhi, sh.ncols)
                for rowx in range(ref3d.rowxlo, rowlim):
                    for colx in range(ref3d.colxlo, collim):
                        cty = sh.cell_type(rowx, colx)
                        if cty == xlrd.XL_CELL_EMPTY and show_contents == 1:
                            continue
                        cval = sh.cell_value(rowx, colx)
                        sval = showable_cell_value(cty, cval, datemode)
                        print("      (%3d,%3d) %-5s: %s"
                            % (rowx, colx, xlrd.cellname(rowx, colx), REPR(sval)), file=f) 
开发者ID:alexfeng,项目名称:InternationalizationScript-iOS,代码行数:42,代码来源:xlrdnameAPIdemo.py

示例11: show_name_object

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def show_name_object(book, nobj, show_contents=0, f=sys.stdout):
    print("\nName: %s, scope: %s (%s)"
        % (REPR(nobj.name), REPR(nobj.scope), scope_as_string(book, nobj.scope)), file=f)
    res = nobj.result
    print("Formula eval result: %s" % REPR(res), file=f)
    if res is None:
        return
    # result should be an instance of the Operand class
    kind = res.kind
    value = res.value
    if kind >= 0:
        # A scalar, or unknown ... you've seen all there is to see.
        pass
    elif kind == xlrd.oREL:
        # A list of Ref3D objects representing *relative* ranges
        for i in range(len(value)):
            ref3d = value[i]
            print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3drel(book, ref3d))), file=f)
    elif kind == xlrd.oREF:
        # A list of Ref3D objects
        for i in range(len(value)):
            ref3d = value[i]
            print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3d(book, ref3d))), file=f)
            if not show_contents:
                continue
            datemode = book.datemode
            for shx in range(ref3d.shtxlo, ref3d.shtxhi):
                sh = book.sheet_by_index(shx)
                print("   Sheet #%d (%s)" % (shx, sh.name), file=f)
                rowlim = min(ref3d.rowxhi, sh.nrows)
                collim = min(ref3d.colxhi, sh.ncols)
                for rowx in range(ref3d.rowxlo, rowlim):
                    for colx in range(ref3d.colxlo, collim):
                        cty = sh.cell_type(rowx, colx)
                        if cty == xlrd.XL_CELL_EMPTY and show_contents == 1:
                            continue
                        cval = sh.cell_value(rowx, colx)
                        sval = showable_cell_value(cty, cval, datemode)
                        print("      (%3d,%3d) %-5s: %s"
                            % (rowx, colx, xlrd.cellname(rowx, colx), REPR(sval)), file=f) 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:42,代码来源:xlrdnameAPIdemo.py

示例12: _fix_value

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def _fix_value(cell):
        """Clean up an Excel value for CSV-like representation."""

        if cell.value is None or cell.ctype == xlrd.XL_CELL_EMPTY:
            return ''

        elif cell.ctype == xlrd.XL_CELL_NUMBER:
            # let numbers be integers if possible
            if float(cell.value).is_integer():
                return int(cell.value)
            else:
                return cell.value

        elif cell.ctype == xlrd.XL_CELL_DATE:
            # dates need to be formatted
            try:
                data = xlrd.xldate_as_tuple(cell.value, 0)
                return '{0[0]:04d}-{0[1]:02d}-{0[2]:02d}'.format(data)
            except:
                return cell.value;

        elif cell.ctype == xlrd.XL_CELL_BOOLEAN:
            return int(cell.value)

        else: # XL_CELL_TEXT, or anything else
            return cell.value 
开发者ID:HXLStandard,项目名称:libhxl-python,代码行数:28,代码来源:io.py

示例13: cell

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import XL_CELL_EMPTY [as 别名]
def cell(self,rdrowx,rdcolx,wtrowx,wtcolx):
        cell = self.rdsheet.cell(rdrowx,rdcolx)
        if cell.ctype == xlrd.XL_CELL_EMPTY:
            return
        if cell.ctype == xlrd.XL_CELL_ERROR:
            logger.error("Cell %s of sheet %r contains a bad value: %s" % (
                        xlrd.cellname(rdrowx, rdcolx),
                        quoted_sheet_name(self.rdsheet.name),
                        cell_display(cell,self.rdbook.datemode),
                        ))
            return
        BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx) 
开发者ID:Scemoon,项目名称:lpts,代码行数:14,代码来源:filter.py


注:本文中的xlrd.XL_CELL_EMPTY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。