Python xlrd.__VERSION__ Examples
The following are 8
code examples of xlrd.__VERSION__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xlrd
, or try the search function
.
Example #1
Source File: test_excel.py From vnpy_crypto with MIT License | 5 votes |
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)
Example #2
Source File: test_excel.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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')
Example #3
Source File: test_excel.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: excel.py From recruit with Apache License 2.0 | 4 votes |
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.')
Example #5
Source File: excel.py From vnpy_crypto with MIT License | 4 votes |
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.')
Example #6
Source File: excel.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
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.')
Example #7
Source File: excel.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
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.')
Example #8
Source File: excel.py From elasticintel with GNU General Public License v3.0 | 4 votes |
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.')