def get_file_type(fname):
    """Attempts to infer the file type by reading the extension.

    **Returns**

    String, one of ["pkl", "hdf", "csv"]

    **Raises**

    `TypeError` if the file type is unrecognized.
    """
    tokens = fname.split(".")
    for token in tokens[::-1]:
        if token in ["pkl"]:
            return "pkl"
        elif token in ["h5", "hdf"]:
            return "hdf"
        elif token in ["csv"]:
            return "csv"
    else:
        raise TypeError("Unrecognized file type: \"{}\".".format(fname))