def sniff_encoding(path):
    """Attempt to sniff and return the file's encoding.""" 
    encodings = ['utf-8', 'latin-1']
    for encoding in encodings:
        try:
            f = open(path, encoding=encoding)
            f.read()
            f.close
            return encoding
        except ValueError:
            continue
    return None