本文整理汇总了Python中pyexcel_io.book.BookReader.open_content方法的典型用法代码示例。如果您正苦于以下问题:Python BookReader.open_content方法的具体用法?Python BookReader.open_content怎么用?Python BookReader.open_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyexcel_io.book.BookReader
的用法示例。
在下文中一共展示了BookReader.open_content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open_content
# 需要导入模块: from pyexcel_io.book import BookReader [as 别名]
# 或者: from pyexcel_io.book.BookReader import open_content [as 别名]
def open_content(self, file_content, **keywords):
if compact.PY27_ABOVE:
import mmap
encoding = keywords.get('encoding', 'utf-8')
if isinstance(file_content, mmap.mmap):
# load from mmap
self.__multiple_sheets = keywords.get('multiple_sheets', False)
self._file_stream = CSVMemoryMapIterator(
file_content, encoding)
self._keywords = keywords
self._native_book = self._load_from_stream()
else:
if compact.PY3_ABOVE:
if isinstance(file_content, bytes):
file_content = file_content.decode(encoding)
# else python 2.7 does not care about bytes nor str
BookReader.open_content(
self, file_content, **keywords)
else:
BookReader.open_content(
self, file_content, **keywords)
示例2: open_content
# 需要导入模块: from pyexcel_io.book import BookReader [as 别名]
# 或者: from pyexcel_io.book.BookReader import open_content [as 别名]
def open_content(self, file_content, **keywords):
try:
import mmap
encoding = keywords.get("encoding", "utf-8")
if isinstance(file_content, mmap.mmap):
# load from mmap
self.__multiple_sheets = keywords.get("multiple_sheets", False)
self._file_stream = CSVMemoryMapIterator(
file_content, encoding
)
self._keywords = keywords
self._native_book = self._load_from_stream()
else:
if compact.PY3_ABOVE:
if isinstance(file_content, bytes):
file_content = file_content.decode(encoding)
# else python 2.7 does not care about bytes nor str
BookReader.open_content(self, file_content, **keywords)
except ImportError:
# python 2.6 or Google app engine
BookReader.open_content(self, file_content, **keywords)