using gzip to uncompress geojson.gz

429
2
Jump to solution
09-11-2021 07:48 AM
rootsmusic
New Contributor III

I downloaded a geojson.gz that I'd like to view and inspect.  I have Python installed, but I don't want to use it to read the file.  What's the command line to gzip it into the same folder?  Thanks.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ShaunWalbridge
Esri Regular Contributor

I'm not sure you want this on the Python forum if you don't want to use Python, but from the command line, if you're working on MacOS or Linux, you can use the command `gunzip`. You'll need to install the same on Windows, or use a tool like 7-zip to extract the content. For future readers who may want to use Python, a solution could look something like this:

 

import gzip
import shutil

with gzip.open('geojson.gz', 'rb') as gz_in:
    with open('geo.json', 'wb') as json_out:
        shutil.copyfileobj(gz_in, json_out)

View solution in original post

2 Replies
ShaunWalbridge
Esri Regular Contributor

I'm not sure you want this on the Python forum if you don't want to use Python, but from the command line, if you're working on MacOS or Linux, you can use the command `gunzip`. You'll need to install the same on Windows, or use a tool like 7-zip to extract the content. For future readers who may want to use Python, a solution could look something like this:

 

import gzip
import shutil

with gzip.open('geojson.gz', 'rb') as gz_in:
    with open('geo.json', 'wb') as json_out:
        shutil.copyfileobj(gz_in, json_out)
rootsmusic
New Contributor III

Thanks @ShaunWalbridge, what I meant was that I didn't want to use Python to view and inspect the extracted files.  I used 7-zip to extract locally in Windows, but I asked because I thought that gzip could have been used instead to do the same.

0 Kudos