I'm trying to analyze the a series of passwords for frequency. My script is working with other input media, however it appears that there's some bad characters in my current data set. How can I get around the "bad" data?
import re
import collections
words = re.findall('\w+', open('rockyou.txt').read().lower())
a=collections.Counter(words).most_common(50)
for word in a:
print(word)
I then get the error:
Traceback (most recent call last):
File "shakecount.py", line 3, in <module>
words = re.findall('\w+', open('rockyou.txt').read().lower().ASCII)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf1 in position 5079963: invalid continuation byte
Any ideas?