當前位置: 首頁>>代碼示例>>Python>>正文


Python parsers.EmptyDataError方法代碼示例

本文整理匯總了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 
開發者ID:pepkit,項目名稱:peppy,代碼行數:20,代碼來源:conftest.py

示例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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_read_fwf.py

示例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) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:11,代碼來源:test_read_fwf.py


注:本文中的pandas.io.parsers.EmptyDataError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。