I'm trying to open up a password database file (consists of a bunch of common passwords) and I'm getting the following error:
Attempts so far.. Code:
f = open("crackstation-human-only.txt", 'r') for i in f: print(i) Error Code:
Traceback (most recent call last): File "C:\Users\David\eclipse-workspace\Kaplin\password_cracker.py", line 3, in <module> for i in f: File "C:\Users\David\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 753: character maps to <undefined> After doing some research I was told to attempt encoding = 'utf-8' which I later discovered was basically guessing and hoping that the file would show all the outputs
Code:
f = open("crackstation-human-only.txt", 'r', encoding = 'utf-8') for i in f: print(i) Error:
Traceback (most recent call last): File "C:\Users\David\eclipse-workspace\Kaplin\password_cracker.py", line 3, in <module> for i in f: File "C:\Users\David\AppData\Local\Programs\Python\Python37\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 5884: invalid continuation byte After receiving this error message, I was recommended to attempt to download a text editor like 'Sublime Text 3', and to open the console end enter the command 'Encoding()', but unfortunately it wasn't able to detect the encoding.
My professor was able to use bash to 'grep cat' the lines in the file (I honestly know very little about bash so if anyone else knows those terms i'm not sure if that will help them out)
If anyone has any suggestions on what I can do in order to get this to work out I would greatly appreciate it.
I will post the link to the text document if anyone is interested in seeing what types of characters are within the file.
Link to the file, it's a .txt from my school/professors domain
UPDATE:
I have a fellow classmate that is running elementary OS, and he was using the terminal to write his python program which would iterate through the file, and he was using the encoding 'latin-1', he was able to output more characters than me, I'm on Windows 10, using Eclipse-atom for all my scripts.
So there seems to be something that's causing me possibly not to get the correct outputs based on these factors, i'm guessing because it just seems that way based on the results,
I will be installing elementary-os and attempting all the solutions there, to see if I can get this file to work out. I'll add another update soon!
f.read(), otherwise you're attempting to read afileinstance.f.read()orf.readlines(). You are actually trying to get elements from file instance not from data inside the instance.'latin-1'? If bothcharmapandutf-8failed then you should try a different one...