當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。