I have lots of json.gz files in a directory and some them are json.gz.part. Supposedly, when saving them, some of the files were too large and they were splitted.
I tried to open them as normally using:
with gzip.open(file, 'r') as fin:
json_bytes = fin.read()
json_str = json_bytes.decode('utf-8') # 2. string (i.e. JSON)
bb = json.loads(json_str)
But when it comes to the .gz.part
files I get an error:
uncompress = self._decompressor.decompress(buf, size)
error: Error -3 while decompressing data: invalid code lengths set
I've tried the jiffyclub's solution, but I get the following error:
_read_eof = gzip.GzipFile._read_eof
AttributeError: type object 'GzipFile' has no attribute '_read_eof'
EDIT:
If I read line by line I'm able to read most of the content file, until I get an error:
with gzip.open(file2,'r') as fin:
for line in fin:
print(line.decode('utf-8'))
After printing most of the content I get:
error: Error -3 while decompressing data: invalid code lengths set
But using this last method I cannot convert its content to a json file.