Created
November 21, 2017 13:01
-
-
Save jweyrich/901c903044062954acba2b88ea4ad8f7 to your computer and use it in GitHub Desktop.
Attempt to detect the charset of files recursively
This file contains hidden or 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
#!/usr/bin/python | |
import chardet | |
import os | |
# traverse root directory, and list directories as dirs and files as files | |
for root, dirs, files in os.walk("."): | |
path = root.split('/') | |
for file in files: | |
print '%s/%s => %s (%s)' % (root, file, chardet.detect(file)['encoding'], chardet.detect(file)['confidence']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment