23 lines
800 B
Python
23 lines
800 B
Python
import re
|
|
import sys
|
|
def write_answer(row, ouput_file):
|
|
with open(ouput_file, "a", encoding="utf-8") as file:
|
|
file.write(row)
|
|
|
|
|
|
def main_function(pattern, input_file, output_file):
|
|
with open(output_file, "w", encoding="utf-8") as output_file1:
|
|
with open(input_file, "r", encoding="utf-8") as file:
|
|
for row in file:
|
|
help_row = row.strip()
|
|
if re.search(pattern, help_row):
|
|
write_answer(row, output_file)
|
|
|
|
# pattern = re.compile(r'(?:^|\s)pies(?:\s|$)', re.IGNORECASE)
|
|
pattern = re.compile(r'.*\b(?:19[0-9]{2}) r\.', re.IGNORECASE)
|
|
|
|
# output_file ='polish_wiki_excerpt.in.out'
|
|
# input_file = 'polish_wiki_excerpt.in'
|
|
input_file = sys.argv[1]
|
|
output_file = sys.argv[2]
|
|
main_function(pattern, input_file, output_file) |