Created
September 25, 2021 19:41
-
-
Save pcnoic/06147a3ba62f6fbdb6212158c36adbf1 to your computer and use it in GitHub Desktop.
search in uncompressed data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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