def detect_file_encoding(fn):
    """
    detect gzip file encoding
    :param fn:
    :return:
    """
    import chardet
    import gzip
    with gzip.open(fn) as f:
        rawdata = f.read()
    encoding = chardet.detect(rawdata)
    return encoding.get('encoding')
