Earlier I wrote the code for extracting a specific string from multiple files and the result is stored in a separate file.Now this file has duplicate results which I need to remove .
import glob
import re
import os.path
path=r"H:\sample"
file_array=glob.glob(os.path.join(path,'*.txt'))
with open("aiq_hits.txt","w") as out_file;
for input_filename in file_array:
with open(input_filename) as in_file:
for line in in_file:
match=re.findall(r"""(?<=')[^']*\.aiq(?=')|(?<=")[^"]*\.aiq(?=")""")
for item in match:
out_file.write("%s\n" %item)
out_file.close()
This out_file has duplicate results which I need to remove and result should be the same file