本文整理匯總了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)