I have a compressed archive: it's a .tar.gz-file. Inside it i have a .tar-archive. And iside this archive there are a bunch of directories and files which contain a .log-files I need. The goal is recursively search through all of directories and files, filtering the ".log"-files and extract its content furthermore. And I do not need to extract it. I just want to search through these logs a specific lines. I'm using Pycharm, python - 3.11, OS - Windows.
Thank you in advance.
It doesn't seem like you can just pass the regex to the archive that has been opened like a:
`file = TarFile.open('H:\path\to\file.tar.gz')
for obj in file.getmembers():
if obj.name == 'Game.log':
print( line for line in obj.readlines())`
Or when I'm trying to give it a fullname like a:
with TarFile.open('H:\path\to\file.tar.gz') as archive:
with archive.open('File.log') as log:
for line in log.readlines():
print(line)
There is an error: "FileNotFoundError: [Errno 2] No such file or directory: 'File.log'"
But since it can give me all files in the archive with .getmembers() maybe it could be a way to get a content specific object?