xxxxxxxxxx
import chardet
def detect_encoding(file_path):
with open(file_path, 'rb') as file:
raw_data = file.read()
result = chardet.detect(raw_data)
return result['encoding']
file_path = 'path_to_your_file' # Replace with the actual file path
encoding = detect_encoding(file_path)
print("File encoding:", encoding)