python Decompress gzip File
import gzip
import shutil
with gzip.open('file.txt.gz', 'rb') as f_in:
with open('file.txt', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
python Decompress gzip File
import gzip
import shutil
with gzip.open('file.txt.gz', 'rb') as f_in:
with open('file.txt', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
python extract gz file
import tarfile
#simple function to extract the train data
#tar_file : the path to the .tar file
#path : the path where it will be extracted
def extract(tar_file, path):
opened_tar = tarfile.open(tar_file)
if tarfile.is_tarfile(tar_file):
opened_tar.extractall(path)
else:
print("The tar file you entered is not a tar file")
extract('/kaggle/input/gnr-638/train.tar.xz', '/kaggle/working/gnr-638')
extract('/kaggle/input/gnr-638/test_set.tar.xz', '/kaggle/working/gnr-638')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us