Skip to content

Instantly share code, notes, and snippets.

@mreid-moz
Created July 4, 2018 16:55
Show Gist options
  • Save mreid-moz/bf82f096e600e438019dd5651ea86e66 to your computer and use it in GitHub Desktop.
Save mreid-moz/bf82f096e600e438019dd5651ea86e66 to your computer and use it in GitHub Desktop.
Decompress ".jsonlz4" files and print their contents
# Uncompress ".jsonlz4" files. See also:
# https://github.com/avih/dejsonlz4
# Requires lz4:
# $ pip install lz4
import lz4.block
import sys
with open(sys.argv[1], "rb") as fin:
content = fin.read()
# Strip the non-standard Mozilla file header.
# The first 8 bytes should be [109, 111, 122, 76, 122, 52, 48, 0]
output_data = lz4.block.decompress(content[8:])
print(output_data)
# TODO: uncompress the file normally if the header does not match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment