Created
July 21, 2023 20:51
-
-
Save billmetangmo/7f0432fe691889821fd96bdc9277bedd to your computer and use it in GitHub Desktop.
Guess encoding (python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chardet | |
def guess_encoding(file): | |
with open(file, 'rb') as f: | |
result = chardet.detect(f.read()) | |
return result['encoding'] | |
encoding = guess_encoding(csv_file) | |
df = pd.read_csv(csv_file, encoding=encoding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment