'How to read/extract contents of .tar.7z file using python

I have a .tar.7z file which I want to unpack (when I unpack with archive_utility.app on MAC manually, I am getting a folder with subfolder and files). I am not able to unpack this .tar.7z file with Python. Please let me know which module will let me do so.

i tried this using tarfile like below and failed to open it.

import tarfile

# open file
# file = tarfile.open('ckrseoselr7202-logs.tar.gz')  # Working
file = tarfile.open('ckrseoselr7202-logs.tar.7z')  # Not Working

# extracting file
file.extractall('./Folder')
  
file.close()

Same way i need to open .tar.7z file and want to read one particular file to parse the data. Let me know how i can achieve this using python3.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source