Here is my code,
for line in open(\'u.item\'):
#read each line
whenever I run this code it gives the following error:
Your file doesn't actually contain utf-8 encoded data, it contains some other encoding. Figure out what that encoding is and use it in the open
call.
In Windows-1252 encoding for example the 0xe9
would be the character é
.
you can try this way:
open('u.item', encoding='utf8', errors='ignore')
You could resolve the problem with:
for line in open(your_file_path, 'rb'):
'rb' is reading file in binary mode. Read more here. Hope this will help!
This works:
open('filename', encoding='latin-1')
or:
open('filename',encoding="ISO-8859-1")