Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

extract .tgz file

tar -xvzf 
Comment

extract tgz files in python

import os, sys, tarfile

def extract(tar_url, extract_path='.'):
    print tar_url
    tar = tarfile.open(tar_url, 'r')
    for item in tar:
        tar.extract(item, extract_path)
        if item.name.find(".tgz") != -1 or item.name.find(".tar") != -1:
            extract(item.name, "./" + item.name[:item.name.rfind('/')])
try:

    extract(sys.argv[1] + '.tgz')
    print 'Done.'
except:
    name = os.path.basename(sys.argv[0])
    print name[:name.rfind('.')], '<filename>'
Comment

PREVIOUS NEXT
Code Example
Python :: pandas series to tuple list 
Python :: python subprocess print stdout while process running 
Python :: ImportError: /home/user/.local/lib/python3.8/site-packages/pytorch3d/_C.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN2at5zerosEN3c108ArrayRefIlEENS0_13TensorOptionsE 
Python :: py mean 
Python :: pandas bin columns 
Python :: python regular expression remove numbers 
Python :: search dictionary for value 
Python :: drop rows from dataframe based on column value 
Python :: how to read a csv file in python 
Python :: how to make an ai 
Python :: the boys 
Python :: python find in list 
Python :: python key list 
Python :: end python program 
Python :: how to get the local time in python 
Python :: python using datetime as id 
Python :: seaborn correlation heatmap 
Python :: how to print all elements of a dictionary in python 
Python :: concat columns pandas dataframe 
Python :: python collections Counter sort by key 
Python :: python how to remove commas from string 
Python :: numpy vector multiplication 
Python :: how to change size of turtle in python 
Python :: time.time() 
Python :: column names pandas 
Python :: import numpy financial python 
Python :: tensor vs numpy array 
Python :: how to aggregate multiple columns in pyspark 
Python :: length of set python 
Python :: append value to numpy array 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =