The json.load, JSONDecodeError: Expecting value: line 1 column 1 (char 0)

4.8K    Asked by IshidaSugiyama in Python , Asked on Apr 16, 2021

I am reading in a json.bz2 file.

This is the code

with open(full_filename, 'r', encoding='utf-8', errors='ignore') as the_file:    

    data = json.load(the_file)

Error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I tried searching on google for solutions, but none of them are working.

Answered by Ishida Sugiyama

You are trying to jsondecodeerror: expecting value: line 1 column 1 (char 0) directly then you need to uncompress it first. You can use the bz2 package. For example:

import json
import bz2
# ...
data = json.loads(bz2.BZ2File(full_filename).read().decode())

Your Answer

Interviews

Parent Categories