import tarfile
import os
file_path = '/scratch/q593a05/NMSC/LANDSAT/sample_data/2021/05/01_08/LC08_L2SP_116035_20210501_20210508_02_T1.tar'
dir_path = file_path.split('.')[0]
if not os.path.exists(dir_path):
    os.mkdir(dir_path)
file = tarfile.open(name=file_path, mode='r', fileobj=None, bufsize=10240)
file.extractall(dir_path)
file.close()
os.remove(file_path)