2021年1月18日星期一

Using python subprocess and 7-zip to extract .tgz file

I am trying to extract a .tgz file by calling 7-zip using the subprocess function (helpful stack overflow post here)

I need to call subprocess twice. First to unzip from .tgz --> .tar and second to unzip from .tar --> .txt

My code successfully unzips the first step, but nothing happens on the second step, any ideas why?

subprocess.Popen([r'C:\Program Files\7-Zip\7z.exe', 'e', '-y', '-r', '-o' + pth, os.path.join(root, 'myZip.tgz')])  subprocess.Popen([r'C:\Program Files\7-Zip\7z.exe', 'e', '-y', '-r', '-o' + pth, os.path.join(pth, 'myZip.tar')])  

"pth" is the output path and "root" is the path where the original zipped file is. I opened up the pth folder and there is in fact a myZip.tar file there.

https://stackoverflow.com/questions/65785335/using-python-subprocess-and-7-zip-to-extract-tgz-file January 19, 2021 at 12:06PM

没有评论:

发表评论