Created
July 4, 2018 16:55
-
-
Save mreid-moz/bf82f096e600e438019dd5651ea86e66 to your computer and use it in GitHub Desktop.
Decompress ".jsonlz4" files and print their contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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