Python detect file's encoding
import chardet def detect_file_encoding(file_path): f = open(file_path, 'r') data = f.read() predict = chardet.detect(data) f.close() return predict['encoding']