def advanced_open(filepath, *args, **kwargs):
    ' Open function interface for files with different extensions.\n\n    Parameters\n    ----------\n    filepath: str\n        File path with extension.\n    args: list\n        Non-key arguments\n    kwargs: dict\n        Key arguments\n\n    Returns\n    -------\n\n    '
    open_fn = open
    if filepath.endswith('.gz'):
        open_fn = gzip.open
    elif filepath.endswith('.bz2'):
        open_fn = bz2.open
    return open_fn(filepath, *args, mode='rt', **kwargs)
Open function interface for files with different extensions.

Parameters
----------
filepath: str
    File path with extension.
args: list
    Non-key arguments
kwargs: dict
    Key arguments

Returns
-------
def advanced_open(filepath, *args, **kwargs):
    ' Open function interface for files with different extensions.\n\n    Parameters\n    ----------\n    filepath: str\n        File path with extension.\n    args: list\n        Non-key arguments\n    kwargs: dict\n        Key arguments\n\n    Returns\n    -------\n\n    '
    open_fn = open
    if filepath.endswith('.gz'):
        open_fn = gzip.open
    elif filepath.endswith('.bz2'):
        open_fn = bz2.open
    return open_fn(filepath, *args, mode='rt', **kwargs)