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


Python xlrd.__VERSION__属性代码示例

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


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

示例1: test_reader_seconds

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import __VERSION__ [as 别名]
def test_reader_seconds(self, ext):
        import xlrd

        # Test reading times with and without milliseconds. GH5945.
        if LooseVersion(xlrd.__VERSION__) >= LooseVersion("0.9.3"):
            # Xlrd >= 0.9.3 can handle Excel milliseconds.
            expected = DataFrame.from_dict({"Time": [time(1, 2, 3),
                                            time(2, 45, 56, 100000),
                                            time(4, 29, 49, 200000),
                                            time(6, 13, 42, 300000),
                                            time(7, 57, 35, 400000),
                                            time(9, 41, 28, 500000),
                                            time(11, 25, 21, 600000),
                                            time(13, 9, 14, 700000),
                                            time(14, 53, 7, 800000),
                                            time(16, 37, 0, 900000),
                                            time(18, 20, 54)]})
        else:
            # Xlrd < 0.9.3 rounds Excel milliseconds.
            expected = DataFrame.from_dict({"Time": [time(1, 2, 3),
                                            time(2, 45, 56),
                                            time(4, 29, 49),
                                            time(6, 13, 42),
                                            time(7, 57, 35),
                                            time(9, 41, 29),
                                            time(11, 25, 22),
                                            time(13, 9, 15),
                                            time(14, 53, 8),
                                            time(16, 37, 1),
                                            time(18, 20, 54)]})

        actual = self.get_exceldf('times_1900', ext, 'Sheet1')
        tm.assert_frame_equal(actual, expected)

        actual = self.get_exceldf('times_1904', ext, 'Sheet1')
        tm.assert_frame_equal(actual, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:38,代码来源:test_excel.py

示例2: _skip_if_no_xlrd

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import __VERSION__ [as 别名]
def _skip_if_no_xlrd():
    try:
        import xlrd
        ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
        if ver < (0, 9):
            pytest.skip('xlrd < 0.9, skipping')
    except ImportError:
        pytest.skip('xlrd not installed, skipping') 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:10,代码来源:test_excel.py

示例3: test_reader_seconds

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import __VERSION__ [as 别名]
def test_reader_seconds(self):
        # Test reading times with and without milliseconds. GH5945.
        import xlrd

        if LooseVersion(xlrd.__VERSION__) >= LooseVersion("0.9.3"):
            # Xlrd >= 0.9.3 can handle Excel milliseconds.
            expected = DataFrame.from_items([("Time",
                                              [time(1, 2, 3),
                                               time(2, 45, 56, 100000),
                                               time(4, 29, 49, 200000),
                                               time(6, 13, 42, 300000),
                                               time(7, 57, 35, 400000),
                                               time(9, 41, 28, 500000),
                                               time(11, 25, 21, 600000),
                                               time(13, 9, 14, 700000),
                                               time(14, 53, 7, 800000),
                                               time(16, 37, 0, 900000),
                                               time(18, 20, 54)])])
        else:
            # Xlrd < 0.9.3 rounds Excel milliseconds.
            expected = DataFrame.from_items([("Time",
                                              [time(1, 2, 3),
                                               time(2, 45, 56),
                                               time(4, 29, 49),
                                               time(6, 13, 42),
                                               time(7, 57, 35),
                                               time(9, 41, 29),
                                               time(11, 25, 22),
                                               time(13, 9, 15),
                                               time(14, 53, 8),
                                               time(16, 37, 1),
                                               time(18, 20, 54)])])

        actual = self.get_exceldf('times_1900', 'Sheet1')
        tm.assert_frame_equal(actual, expected)

        actual = self.get_exceldf('times_1904', 'Sheet1')
        tm.assert_frame_equal(actual, expected) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:40,代码来源:test_excel.py

示例4: __init__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import __VERSION__ [as 别名]
def __init__(self, filepath_or_buffer):
        """Reader using xlrd engine.

        Parameters
        ----------
        filepath_or_buffer : string, path object or Workbook
            Object to be parsed.
        """
        err_msg = "Install xlrd >= 1.0.0 for Excel support"

        try:
            import xlrd
        except ImportError:
            raise ImportError(err_msg)
        else:
            if xlrd.__VERSION__ < LooseVersion("1.0.0"):
                raise ImportError(err_msg +
                                  ". Current version " + xlrd.__VERSION__)

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

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

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

示例5: __init__

# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import __VERSION__ [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 __VERSION__ [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.__VERSION__属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。