Reads index from file.

    Args:
        fn (str): the name of the file containing the index.

    Returns:
        pandas.DataFrame: the index of the file.

    Before reading the index, we check the first couple of bytes to see if it
    is a valid index file.

def read_index(fn):
    """Reads index from file.

    Args:
        fn (str): the name of the file containing the index.

    Returns:
        pandas.DataFrame: the index of the file.

    Before reading the index, we check the first couple of bytes to see if it
    is a valid index file.

    """
    index = None
    with open(fn, "rb") as i_file:
        if i_file.read(len(_CHECK_STRING)) != _CHECK_STRING:
            raise ValueError("{}: not a valid index file".format(fn))

        index = pd.read_csv(io.StringIO(
            zlib.decompress(i_file.read()).decode(encoding="utf-8"),
        ))

    return index