本文整理汇总了Python中pandas.io.parsers.EmptyDataError方法的典型用法代码示例。如果您正苦于以下问题:Python parsers.EmptyDataError方法的具体用法?Python parsers.EmptyDataError怎么用?Python parsers.EmptyDataError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.parsers
的用法示例。
在下文中一共展示了parsers.EmptyDataError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create
# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import EmptyDataError [as 别名]
def _create(request, data_type, **kwargs):
"""
Create instance of desired type, using file in request class.
:param _pytest.fixtures.FixtureRequest: test case that initiated the
fixture request that triggered this call
:param type data_type: the data type to be created
"""
request_class_attr_name = _ATTR_BY_TYPE[data_type]
data_source = request_class_attribute(request, request_class_attr_name)
_LOGGER.debug("Using %s as source of data to build %s",
data_source, data_type.__class__.__name__)
try:
return data_type(data_source, **kwargs)
except EmptyDataError:
with open(data_source, 'r') as datafile:
_LOGGER.error("File contents:\n{}".format(datafile.readlines()))
raise
示例2: test_skiprows_inference_empty
# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import EmptyDataError [as 别名]
def test_skiprows_inference_empty():
data = """
AA BBB C
12 345 6
78 901 2
""".strip()
msg = "No rows from which to infer column width"
with pytest.raises(EmptyDataError, match=msg):
read_fwf(StringIO(data), skiprows=3)
示例3: test_skiprows_inference_empty
# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import EmptyDataError [as 别名]
def test_skiprows_inference_empty(self):
test = """
AA BBB C
12 345 6
78 901 2
""".strip()
with pytest.raises(EmptyDataError):
read_fwf(StringIO(test), skiprows=3)