1

I would like to import the JSON file located at "https://www.drivy.com/cars/458342/reviews?page=1&paginate_per=6&rel=next" in python.

When I run this:

with open('C:/Users/coppe/Documents/py trials/eval.json') as json_file:  
reviews = json.load(json_file)

I get an error:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 6776: character maps to <undefined>

Actually this error is due to a special character contained in the html keyvalue. Knowing that this character is an emoticon (a thumb), how can I still import my JSON by ignoring this ?

0

2 Answers 2

4

You need to specify the correct format for the json encoder to use. Most use utf8, therefore use something like:

reviews = json.load(
    open("C:/Users/coppe/Documents/py trials/eval.json", encoding="utf8")
)

or

with open('C:/Users/coppe/Documents/py trials/eval.json') as json_file:
    reviews = json.load(json_file, encoding="utf8")

Good Luck!

Sign up to request clarification or add additional context in comments.

Comments

1

use

open(json_file, encoding="utf8")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.