Python pandas.io.parsers.EmptyDataError() Examples

The following are 6 code examples of pandas.io.parsers.EmptyDataError(). 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 pandas.io.parsers , or try the search function .
Example #1
Source File: conftest.py    From peppy with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 
Example #2
Source File: test_read_fwf.py    From recruit with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: test_read_fwf.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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) 
Example #4
Source File: test_read_fwf.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source File: test_read_fwf.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: test_read_fwf.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
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)