Python pandas.compat.FileNotFoundError() Examples

The following are 10 code examples of pandas.compat.FileNotFoundError(). 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.compat , or try the search function .
Example #1
Source File: s3.py    From recruit with Apache License 2.0 7 votes vote down vote up
def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
                           compression=None, mode=None):

    if mode is None:
        mode = 'rb'

    fs = s3fs.S3FileSystem(anon=False)
    try:
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    except (compat.FileNotFoundError, NoCredentialsError):
        # boto3 has troubles when trying to access a public file
        # when credentialed...
        # An OSError is raised if you have credentials, but they
        # aren't valid for that bucket.
        # A NoCredentialsError is raised if you don't have creds
        # for that bucket.
        fs = s3fs.S3FileSystem(anon=True)
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    return filepath_or_buffer, None, compression, True 
Example #2
Source File: test_common.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_nonexistent_path(all_parsers):
    # gh-2428: pls no segfault
    # gh-14086: raise more helpful FileNotFoundError
    parser = all_parsers
    path = "%s.csv" % tm.rands(10)

    msg = ("does not exist" if parser.engine == "c"
           else r"\[Errno 2\]")
    with pytest.raises(compat.FileNotFoundError, match=msg) as e:
        parser.read_csv(path)

        filename = e.value.filename
        filename = filename.decode() if isinstance(
            filename, bytes) else filename

        assert path == filename 
Example #3
Source File: s3.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
                           compression=None, mode=None):

    if mode is None:
        mode = 'rb'

    fs = s3fs.S3FileSystem(anon=False)
    try:
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    except (compat.FileNotFoundError, NoCredentialsError):
        # boto3 has troubles when trying to access a public file
        # when credentialed...
        # An OSError is raised if you have credentials, but they
        # aren't valid for that bucket.
        # A NoCredentialsError is raised if you don't have creds
        # for that bucket.
        fs = s3fs.S3FileSystem(anon=True)
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    return filepath_or_buffer, None, compression, True 
Example #4
Source File: test_common.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_nonexistent_path(all_parsers):
    # gh-2428: pls no segfault
    # gh-14086: raise more helpful FileNotFoundError
    parser = all_parsers
    path = "%s.csv" % tm.rands(10)

    msg = ("does not exist" if parser.engine == "c"
           else r"\[Errno 2\]")
    with pytest.raises(compat.FileNotFoundError, match=msg) as e:
        parser.read_csv(path)

        filename = e.value.filename
        filename = filename.decode() if isinstance(
            filename, bytes) else filename

        assert path == filename 
Example #5
Source File: s3.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
                           compression=None, mode=None):

    if mode is None:
        mode = 'rb'

    fs = s3fs.S3FileSystem(anon=False)
    try:
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    except (compat.FileNotFoundError, NoCredentialsError):
        # boto3 has troubles when trying to access a public file
        # when credentialed...
        # An OSError is raised if you have credentials, but they
        # aren't valid for that bucket.
        # A NoCredentialsError is raised if you don't have creds
        # for that bucket.
        fs = s3fs.S3FileSystem(anon=True)
        filepath_or_buffer = fs.open(_strip_schema(filepath_or_buffer), mode)
    return filepath_or_buffer, None, compression, True 
Example #6
Source File: test_common.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_read_non_existant_read_table(self):
        path = os.path.join(HERE, 'data', 'does_not_exist.' + 'csv')
        msg1 = r"File b'.+does_not_exist\.csv' does not exist"
        msg2 = (r"\[Errno 2\] File .+does_not_exist\.csv does not exist:"
                r" '.+does_not_exist\.csv'")
        with pytest.raises(FileNotFoundError, match=r"({}|{})".format(
                msg1, msg2)):
            with tm.assert_produces_warning(FutureWarning):
                pd.read_table(path) 
Example #7
Source File: common.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_nonexistent_path(self):
        # gh-2428: pls no segfault
        # gh-14086: raise more helpful FileNotFoundError
        path = '%s.csv' % tm.rands(10)
        pytest.raises(compat.FileNotFoundError, self.read_csv, path) 
Example #8
Source File: test_common.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_read_non_existant_read_table(self):
        path = os.path.join(HERE, 'data', 'does_not_exist.' + 'csv')
        msg1 = r"File b'.+does_not_exist\.csv' does not exist"
        msg2 = (r"\[Errno 2\] File .+does_not_exist\.csv does not exist:"
                r" '.+does_not_exist\.csv'")
        with pytest.raises(FileNotFoundError, match=r"({}|{})".format(
                msg1, msg2)):
            with tm.assert_produces_warning(FutureWarning):
                pd.read_table(path) 
Example #9
Source File: common.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_nonexistent_path(self):
        # gh-2428: pls no segfault
        # gh-14086: raise more helpful FileNotFoundError
        path = '%s.csv' % tm.rands(10)
        pytest.raises(compat.FileNotFoundError, self.read_csv, path) 
Example #10
Source File: common.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_nonexistent_path(self):
        # gh-2428: pls no segfault
        # gh-14086: raise more helpful FileNotFoundError
        path = '%s.csv' % tm.rands(10)
        pytest.raises(compat.FileNotFoundError, self.read_csv, path)