My tar.gz is created in Linux.
I am trying to extract in windows using python3. I use this following program.
import tarfile archive_name = "adcnsaup01-20170720.tar.gz" def recover(name): return str(name) tar = tarfile.open(name=archive_name, mode='r', bufsize=16*1024) updated = [] for m in tar.getmembers(): m.name = recover(m.name) updated.append(m) tar.extractall(members=updated) tar.close()
Printing the members “updated” , lists down all the contents on the tar.gz But extract all does not extract π
Tried even this program:
import tarfile tfilemember = [] filen = "adcnsaup01-techdata-20170720.tar.gz" tar11 = tarfile.open(filen, "r:gz") for tarinfo in tar11: tfilemember.append(tarinfo.name) print (tarinfo.name, "is", tarinfo.size, "bytes in size and is", end = "") if tarinfo.isreg(): print ("a regular file.") elif tarinfo.isdir(): print ("a directory.") else: print ("something else.") tar11.extractall(path="D:\outdir\try1")
Prints the list of files if it is a diectory or file. but doesnot extract π Any idea why?