Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
ccinet
on 15/03/2024, 21:45:21 UTC
Hello everyone.

I need a Python script that would check two text files, and if the text in the lines matches, then the script would write “Match found” and write the matching text to a new file. If there is no match, then it would write “No matches found.”

Can anyone help?

I write it in my native language...

def encontrar_coincidencias(archivo1, archivo2, archivo_salida):
    with open(archivo1, 'r') as f1, open(archivo2, 'r') as f2, open(archivo_salida, 'w') as output_file:
        lineas1 = f1.readlines()
        lineas2 = f2.readlines()
       
        coincidencias = False
       
        for linea1, linea2 in zip(lineas1, lineas2):
            if linea1.strip() == linea2.strip():
                coincidencias = True
                output_file.write(linea1)
       
        if coincidencias:
            print("Coincidencia encontrada")
        else:
            print("No se encontraron coincidencias")

# Llamada a la función con los archivos de entrada y salida
archivo1 = "archivo1.txt"
archivo2 = "archivo2.txt"
archivo_salida = "coincidencias.txt"

encontrar_coincidencias(archivo1, archivo2, archivo_salida)