Hi,
Kindly your support to provide python script to search given strings (Number, Text etc.) from multiple ".gz" text files
Directory contains multiple".gz" files date wise
Kindly your support to provide python script to search given strings (Number, Text etc.) from multiple ".gz" text files
Directory contains multiple".gz" files date wise
Output:/bkup/TC/XYZ/20210818
File Names:
A_7235818.csv.gz
A_7235819.csv.gz
.
.
Output:Content of sample file.
38486,22625,XYZ_06_0_20210817204446-3997
88279,77617,XYZ_06_0_20210817204846-3998
Getting error while running below Code.import glob import gzip matched_lines = [] ZIPFILES='/bkup/TC/XYZ/20210818/*.gz' grep = raw_input('Enter Search: ') filelist = glob.glob(ZIPFILES) for gzfile in filelist: #print("#Starting " + gzfile) #if you want to know which file is being processed with gzip.open( gzfile, 'rb') as f: # grep = raw_input('Enter Search: ') for line in f: # read file line by line if grep in line: # search for string in each line matched_lines.append(line) # keep a list of matched lines file_content = ''.join(matched_lines) # join the matched lines print(file_content)Output:
Error:$ ./srch6.py
File "./srch6.py", line 17
for line in f: # read file line by line
^
IndentationError: expected an indented block
Larz60+ write Aug-18-2021, 11:20 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed for you this time, please use bbcode tags on future posts
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed for you this time, please use bbcode tags on future posts