Skip to content

Instantly share code, notes, and snippets.

@billmetangmo
Created July 21, 2023 20:51
Show Gist options
  • Save billmetangmo/7f0432fe691889821fd96bdc9277bedd to your computer and use it in GitHub Desktop.
Save billmetangmo/7f0432fe691889821fd96bdc9277bedd to your computer and use it in GitHub Desktop.
Guess encoding (python)
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