It's fairly common to compress large CSV and TXT files using the gzip compression algorithm (GNU zip) to allow for more efficient file storage and transfer. The gzip tool reduces the size of files and adds a .gz extension to the compressed file. When you gunzip a file, you're reversing the compression process, restoring the file to its original, uncompressed state.
It can be a challenge to open .gz files in Excel and Google Sheets. Fortunately, Row Zero is a free and easy way to unzip and open .gz files online. Row Zero is spreadsheet built for big data, including billion row, multi-GB .gz, csv.gz, and txt.gz files.
There are several ways to unzip and open large .gz files, depending on your needs and technical skills. Skip to specific sections using the links below or continue reading for the full guide.
- Easily open .gz files in a spreadsheet
- Open csv.gz and txt.gz files
- Convert csv.gz to csv
- Unzip a .gz file Windows
- Unzip a .gz file Linux or Mac
- Unzip a tar.gz file
- Extract a .gz file with Python
- Open a .gz file in Excel
- Open a .gz file in Google Sheets
- How to compress and gzip a file
- Conclusion
Easily open gz files online in a spreadsheet
If you want to open a .gz file in a spreadsheet, Row Zero is your best choice. Row Zero automatically unzips and opens .gz files like csv.gz and txt.gz files with delimiters. More importantly, Row Zero can handle very large, billion row files, so you can view and edit your uncompressed file with ease. Here's how in 3 easy steps:
Open up a workbook in Row Zero
Row Zero is an online spreadsheet built for big data. Login or sign up for free to get started.Import your .gz file: In the top navigation, click Data to import your .gz file from your computer, from a URL, or directly from Amazon S3. Row Zero handles delimiters automatically, but if needed, you can click Advanced options to customize. Then click Import.
View and edit your .gz file as a spreadsheet
Your .gz file is now a spreadsheet in Row Zero, and you can make any edits and transformations like pivot tables, graphs, COUNTIFS, VLOOKUP, etc. Here's an example .gz file of a log of NY state hospital admissions from 2020-2021. The uncompressed file is several million rows and the .gz file easily unzips and opens instantly.
Open csv.gz and txt.gz files
Row Zero automatically unzips and opens csv.gz and txt.gz files. Same as the steps above, simply upload your .gz file to Row Zero. Row Zero will gunzip the .gz file and open the original .csv or .txt file. Row Zero is a good program to use, because the original files are likely large and Row Zero can open and edit very large CSV files up to 2 billion rows and also open large txt files with delimiters.
Convert csv.gz to csv
You can easily convert csv.gz to .csv using Row Zero. Similar to the steps above, simply upload your .gz file to Row Zero. Feel free to make any edits or transformations and then go to File, Download as CSV.
Unzip a gz file on Windows
To unzip a .gz file on Windows you'll need a third-party software program like WinRAR or 7-Zip. Here are instructions to gunzip on Windows for each:
WinRAR:
- Download and install WinRAR.
- Right-click the .gz file.
- Choose Extract Here or Extract to "folder-name".
7-Zip:
- Download and install 7-Zip.
- Right-click the .gz file.
- Choose 7-Zip > Extract Here or Extract to "folder-name".
This will extract the original file. Note that the file may be large since the original file was compressed with gzip to reduce it's size. Therefor the file may be too large for Excel or other Windows programs and you may need a more powerful spreadsheet like Row Zero to open and edit large files.
Unzip a gz file on Linux or Mac
To unzip a gz file on mac or linux, you can use the command line. To extract a .gz file and keep both the original .gz file and the decompressed file:
gunzip file.gz
To extract the decompressed file and delete the original .gz file:
gunzip -d file.gz
Unzip a tar.gz file
The TAR file format is used to bundle multiple files into a single file. This is useful for packaging a collection of files and directories into a single archive. The TAR file itself is not compressed. It just aggregates files together. The resulting file has the .tar extension. A tar.gz file format is created by first using TAR to bundle files together into a .tar archive and then compressing that archive using GZIP, resulting in a .tar.gz file.
To unzip a tar.gz file in Linux or Mac, you can use the command line:
tar -xzvf file.tar.gz
To unzip a tar.gz file in Windows, you'll need to download a program like WinRAR or 7-Zip following the instructions above.
Extract a gz file with Python
You can extract .gz files with Python programmatically using the following code:
import gzip import shutil with gzip.open('file.gz', 'rb') as f_in: with open('file', 'wb') as f_out: shutil.copyfileobj(f_in, f_out)
This will decompress the .gz file into the original file.
Open a gz file in Excel
Excel does not open .gz files natively. You'll need to extract the .csv file from the .gz archive first (same for .txt.gz).
The simplest thing to do is just open your csv.gz or txt.gz file in Row Zero. Row Zero is similar to Excel, but was built for big data and can open billion row files. If needed, you can then download the file as CSV and open it in Excel, assuming the file isn't too big for Excel's row limit of 1,048,576 rows. You can also follow the instructions above for extracting .gz files in Windows.
See why Row Zero is a good Excel replacement for big data.
Open a gz file in Google Sheets
Similar to Excel, Google Sheets does not open .gz files natively. You'll need to gunzip the .csv.gz file (or txt.gz file) back to it's original .csv file before opening in Google Sheets.
Again, the easiest thing to do is just open your txt.gz or csv.gz file in Row Zero and then you're good to go. After that, if you still need it in Google Sheets, you can download as CSV and import to Google Sheets, assuming the file isn't too big for the Google Sheets 10 million cell limit.
See why Row Zero is a good alternative to Google Sheets for big data.
How to compress and gzip a file
To compress and gzip a file, you can follow these steps based on your operating system:
Gzip a file on Linux or macOS:
Compress a single file using the gzip command:
gzip filename
This command will compress the file 'filename' and create a new file called 'filename.gz'.
Compress and gzip multiple files into a single archive:
First, create a .tar archive containing multiple files:
tar -cvf archive.tar file1 file2 file3
Replace file1, file2, and file3 with the names of the files you want to compress. Then, gzip the .tar archive:
gzip archive.tar
This will create archive.tar.gz.
Compress an entire directory:
To compress all files and subdirectories within a directory:
tar -czvf archive.tar.gz /path/to/directory
Replace /path/to/directory with the directory you want to compress. The -c flag creates a new archive, -z compresses it with gzip, -v gives you verbose output (optional), and -f specifies the file name.
Gzip a file on Windows:
Using WinRAR:
- Download and install WinRAR.
- Right-click the file or directory you want to compress.
- Choose Add to archive....
- Set the archive format to GZIP.
- Click OK to create the .gz file.
Using 7-Zip:
- Download and install 7-Zip.
- Right-click the file or directory you want to compress.
- Choose 7-Zip > Add to archive....
- In the dialog box, set the following:
- Archive format: gzip
- Compression level: Choose a compression level (e.g., Normal, Ultra).
- Archive name: Set the desired name (e.g., filename.gz).
- Click OK to create the .gz file.
Gzip a file with Python:
You can compress and gzip a file with Python programmatically:
import gzip import shutil with open('filename', 'rb') as f_in: with gzip.open('filename.gz', 'wb') as f_out: shutil.copyfileobj(f_in, f_out)
This script reads the contents of 'filename' and writes the compressed data to 'filename.gz'.
Conclusion
The .gz file extension and gzip compression algorithm allow you to reduce large file sizes for efficient storage and transfer. You can easily gunzip the .gz file to extract the original file. Row Zero makes it very easy to open CSV.gz and txt.gz files with delimiters. Most importantly, Row Zero supports billion row file sizes so you can easily open and edit the decompressed files. Ready to get started?