Error reading file with accented vowels

Posted by Daniel Dcs on Stack Overflow See other posts from Stack Overflow or by Daniel Dcs
Published on 2013-10-21T03:46:39Z Indexed on 2013/10/21 3:53 UTC
Read the original article Hit count: 101

Filed under:
|

The following statement to fill a list from a file :

action = []

with open (os.getcwd() + "/files/" + "actions.txt") as temp:
         action = list (temp)

gives me the following error:

(result, consumed) = self._buffer_decode (data, self.errors, end)
UnicodeDecodeError: 'utf-8' codec can not decode byte 0xf1 in position 67: invalid continuation byte

if I add errors = 'ignore':

action = []

with open (os.getcwd () + "/ files /" + "actions.txt", errors = 'ignore') as temp:
         action = list (temp)

Is read the file but not the ñ and vowels accented á-é-í-ó-ú being that python 3 works, as I have understood, default to 'utf-8'

I'm looking for a solution for two or more days, and I'm getting more confused.

In advance thank you very much for any suggestions.

© Stack Overflow or respective owner

Related posts about python

Related posts about utf-8