I have two text files, file1.txt and file2.txt, that I need to compare and remove duplicate lines. The two files are not equal in size.
I've tried using filecmp
and openfiles
, but they do not work.
with open('crones.txt', 'r') as file1:
with open('destino.txt', 'r+') as file2:
lineas = file1.readlines()
same = set(file1).intersection(file2)
file2.close()
file1.close()
#file1 = open("crones.txt","w")
#for linea in lineas:
# if linea!=same+"\n":
# f.write(linea)
print same
print lineas
#same.discard('\n')
#with open('some_output_file.txt', 'w') as FO:
# for line in same:
# FO.write(line)