Skip to content

Instantly share code, notes, and snippets.

@pcnoic
Created September 25, 2021 19:41
Show Gist options
  • Save pcnoic/06147a3ba62f6fbdb6212158c36adbf1 to your computer and use it in GitHub Desktop.
Save pcnoic/06147a3ba62f6fbdb6212158c36adbf1 to your computer and use it in GitHub Desktop.
search in uncompressed data
import py7zr
import sys
import os
f = sys.argv[1]
s_term = sys.argv[2]
d_input = os.listdir(path='./')
with py7zr.SevenZipFile(f, mode='r') as z:
z.extractall()
for fname in d_input:
if fname.endswith('txt'):
fo = open(d_input + fname)
line = fo.readline()
line_no = 1
while line != '':
index = line.find(s_term)
if (index != -1):
print(fname, "[", line_no, ",", index, "] ", line, sep="")
line = fo.readline()
line_no += 1
fo.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment