0

I tried reading the text file using Python but I am getting below error.

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 1593: character maps to

I am using Anaconda version 3.6.

Can anyone help to resolve this issue?

Thanks in advance.

Sekhar
  • 627
  • 4
  • 14
  • 34
  • show your code. we don't know what you use to read it. BTW: title should be short, don't put all problem in title. – furas Dec 08 '17 at 09:24
  • 1
    problem can be python uses some most popular decoding to read file - it can be ie. `Latin-1`, `Utf-8`, `ASCII` - but your file has data in different encoding and you have to set corect when you read it. Different functions may need different solutions. Use Google to see in what encoding can be 0x8f. – furas Dec 08 '17 at 09:29
  • file = open('inpfile.txt','r') for line in file: print(line) – Sekhar Dec 08 '17 at 11:10
  • Hi Furas, thanks for support. It worked for me with encoding="latin-1". – Sekhar Dec 08 '17 at 11:40
  • @tripleee This question isn't a duplicate of that one. The errors don't even match (UnicodeEncodeError vs. UnicodeDecodeError). This question deals with detecting the encoding of input and the proposed duplicate deals with getting the correct encoding for output. – Jason R. Coombs Dec 08 '17 at 15:52

0 Answers0