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


Python xlrd.Book方法代码示例

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


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

示例1: get_workbooks

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def get_workbooks(self):
        """
        If the data to be processed is not stored in files or if
        special parameters need to be passed to :func:`xlrd.open_workbook`
        then this method must be overriden.
        Any implementation must return an iterable sequence of tuples.
        The first element of which must be an :class:`xlrd.Book` object and the
        second must be the filename of the file from which the book
        object came.
        """
        for path in self.get_filepaths():
            yield (
                xlrd.open_workbook(
                    path,
                    formatting_info=1,
                    on_demand=True,
                    ragged_rows=True),
                os.path.split(path)[1]
                ) 
开发者ID:Scemoon,项目名称:lpts,代码行数:21,代码来源:filter.py

示例2: __call__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def __call__(self, filter):
        """
        Once instantiated, a reader will be called and have the first
        filter in the chain passed to its :meth:`__call__` method.
        The implementation of this method
        should call the appropriate methods on the filter based on the
        cells found in the :class:`~xlrd.Book` objects returned from the
        :meth:`get_workbooks` method.
        """
        filter.start()
        for workbook,filename in self.get_workbooks():
            filter.workbook(workbook,filename)
            for sheet_x in range(workbook.nsheets):
                sheet = workbook.sheet_by_index(sheet_x)
                filter.sheet(sheet,sheet.name)
                for row_x in xrange(sheet.nrows):
                    filter.row(row_x,row_x)
                    for col_x in xrange(sheet.row_len(row_x)):
                        filter.cell(row_x,col_x,row_x,col_x)
                if workbook.on_demand:
                    workbook.unload_sheet(sheet_x)
        filter.finish() 
开发者ID:Scemoon,项目名称:lpts,代码行数:24,代码来源:filter.py

示例3: __init__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def __init__(self, io, engine=None):
        if engine is None:
            engine = 'xlrd'
        if engine not in self._engines:
            raise ValueError("Unknown engine: {engine}".format(engine=engine))

        # could be a str, ExcelFile, Book, etc.
        self.io = io
        # Always a string
        self._io = _stringify_path(io)

        self._reader = self._engines[engine](self._io) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:excel.py

示例4: workbook

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def workbook(self,rdbook,wtbook_name):
        """
        This method is called every time processing of a new
        workbook starts.

        :param rdbook: the :class:`~xlrd.Book` object from which the new workbook
                 should be created.

        :param wtbook_name: the name of the workbook into which content
                      should be written.
        """
        self.next.workbook(rdbook,wtbook_name) 
开发者ID:Scemoon,项目名称:lpts,代码行数:14,代码来源:filter.py

示例5: __init__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def __init__(self, io, **kwds):

        err_msg = "Install xlrd >= 0.9.0 for Excel support"

        try:
            import xlrd
        except ImportError:
            raise ImportError(err_msg)
        else:
            ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
            if ver < (0, 9):  # pragma: no cover
                raise ImportError(err_msg +
                                  ". Current version " + xlrd.__VERSION__)

        # could be a str, ExcelFile, Book, etc.
        self.io = io
        # Always a string
        self._io = _stringify_path(io)

        engine = kwds.pop('engine', None)

        if engine is not None and engine != 'xlrd':
            raise ValueError("Unknown engine: {engine}".format(engine=engine))

        # If io is a url, want to keep the data as bytes so can't pass
        # to get_filepath_or_buffer()
        if _is_url(self._io):
            io = _urlopen(self._io)
        elif not isinstance(self.io, (ExcelFile, xlrd.Book)):
            io, _, _, _ = get_filepath_or_buffer(self._io)

        if engine == 'xlrd' and isinstance(io, xlrd.Book):
            self.book = io
        elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
            # N.B. xlrd.Book has a read attribute too
            if hasattr(io, 'seek'):
                try:
                    # GH 19779
                    io.seek(0)
                except UnsupportedOperation:
                    # HTTPResponse does not support seek()
                    # GH 20434
                    pass

            data = io.read()
            self.book = xlrd.open_workbook(file_contents=data)
        elif isinstance(self._io, compat.string_types):
            self.book = xlrd.open_workbook(self._io)
        else:
            raise ValueError('Must explicitly set engine if not passing in'
                             ' buffer or path for io.') 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:53,代码来源:excel.py

示例6: __init__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import Book [as 别名]
def __init__(self, io, **kwds):

        err_msg = "Install xlrd >= 0.9.0 for Excel support"

        try:
            import xlrd
        except ImportError:
            raise ImportError(err_msg)
        else:
            ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
            if ver < (0, 9):  # pragma: no cover
                raise ImportError(err_msg +
                                  ". Current version " + xlrd.__VERSION__)

        # could be a str, ExcelFile, Book, etc.
        self.io = io
        # Always a string
        self._io = _stringify_path(io)

        engine = kwds.pop('engine', None)

        if engine is not None and engine != 'xlrd':
            raise ValueError("Unknown engine: {engine}".format(engine=engine))

        # If io is a url, want to keep the data as bytes so can't pass
        # to get_filepath_or_buffer()
        if _is_url(self._io):
            io = _urlopen(self._io)
        elif not isinstance(self.io, (ExcelFile, xlrd.Book)):
            io, _, _ = get_filepath_or_buffer(self._io)

        if engine == 'xlrd' and isinstance(io, xlrd.Book):
            self.book = io
        elif not isinstance(io, xlrd.Book) and hasattr(io, "read"):
            # N.B. xlrd.Book has a read attribute too
            data = io.read()
            self.book = xlrd.open_workbook(file_contents=data)
        elif isinstance(self._io, compat.string_types):
            self.book = xlrd.open_workbook(self._io)
        else:
            raise ValueError('Must explicitly set engine if not passing in'
                             ' buffer or path for io.') 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:44,代码来源:excel.py


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