aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pandas/py2/pandas/io/gcs.py
blob: aa1cb648f05d1caa91a30ef5f1605bc29c398a8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
""" GCS support for remote file interactivity """
try:
    import gcsfs
except ImportError:
    raise ImportError("The gcsfs library is required to handle GCS files")


def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
                           compression=None, mode=None):

    if mode is None:
        mode = 'rb'

    fs = gcsfs.GCSFileSystem()
    filepath_or_buffer = fs.open(filepath_or_buffer, mode)
    return filepath_or_buffer, None, compression, True