I'm new here and in the world of Python scripting mostly with the arcpy module. I hope you can help me with the trouble that I have.
I'm trying to develop a script to extract or uncompress multiple tar.gz files (I can do it properly) with the condition that if the file into the tar.gz file contains certain name only.
import os, tarfile, glob
ws = "workspace" out = "out workspace"
for tar_file in glob.glob(ws + "/*.gz"):
tar = tarfile.open(tar_file,"r")
for member in tar.getmembers():
if "atribute 1" or "atribute 2" in member.name: # here i'm failing
tar.extract(member,out)
print "%s extracted" %(member)
tar.close()
I can´t create the condition if. Any idea how can I uncompress only the files with the attributes that I want? I'm trying to do this to extract only some bands of a huge LANDSAT 8 dataset.