Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Utf 8 Codec Can't Decode Bytes In Position 15 16 Invalid Continuation Byte
Next
In Process
Noelle Singh
  • 18
Noelle Singh
Asked: April 22, 20222022-04-22T02:32:46+00:00 2022-04-22T02:32:46+00:00In: python

Utf 8 Codec Can’t Decode Bytes In Position 15 16 Invalid Continuation Byte

  • 18

. Advertisement .

..3..

. Advertisement .

..4..

What are the best answers for ‘utf-8’ codec can’t decode bytes in position 15-16: invalid continuation byte

♦ Suggestions of ITtutoria Team
Ideas for ‘utf-8’ codec can’t decode bytes in position 15-16: invalid continuation byte: UTF-8 is a Unicode encoding standard for writing most of the alphabets of the world. It has many advantages over other encoding standards, like Windows-1252. However, in order to do so, it requires bytes to be placed within its range of 0-255 at a specific location. An invalid continuation byte is when this happens and causes problems with how the UTF-8 codec decodes text.

Here is a suggestion for you

import pandas as pd
data = pd.read_csv(filename, encoding= 'unicode_escape')
  • 5 5 Answers
  • 225 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

5 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Ronan Miller
    2022-04-22T02:33:04+00:00Added an answer on April 22, 2022 at 2:33 am
    pd.read_csv('ml-100k/u.item', sep='|', names=m_cols , encoding='latin-1')
    • 21
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Kali Gelbero
    2022-04-22T02:33:02+00:00Added an answer on April 22, 2022 at 2:33 am
    # Use 'ISO-8859-1' instead of "utf-8" for decoding
    text = open(fn, 'rb').read().decode('ISO-8859-1')
    • 17
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. Mia Rodriguez
    2022-04-22T02:32:55+00:00Added an answer on April 22, 2022 at 2:32 am

    It seems this solution works, you may try it

    # Use the correct enconding of your file, for me it was ISO-8859-1
    with open("file.txt", "r", encoding="ISO-8859-1") as txt_file:
        # Your Code
    • 17
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  4. Mara O'Neill
    2022-04-22T02:32:52+00:00Added an answer on April 22, 2022 at 2:32 am

    Hope that my example would help

    import pandas as pd
    data = pd.read_csv(filename, encoding= 'unicode_escape')
    • 19
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  5. Reece Morton
    2022-04-22T02:32:50+00:00Added an answer on April 22, 2022 at 2:32 am

    In case you expect more than one maximum this will work

    #use rb over r
    with open(path, 'rb') as f:
      text = f.read()
    • 17
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.