import gzip
import json
with gzip.open("collection_ids_07_01_2023.json.gz", "rb") as f:
data = json.loads(f.read().decode("utf-8"))
i get an error :
data = json.loads(f.read().decode("utf-8"))
File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python311\Lib\json\decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 40)
by chance does anyone know the encoding to use with a json.gz fron TMDB
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by robbie3999
on July 2, 2023 at 11:18 AM
Hi @999sbo999, my python is a little rusty but I believe "f.read()" reads the entire file.
From the docs:
So you are feeding the json decoder the entire file which is not a valid json object. You need to decode the json line by line.