Is it possible to check that the values obtained in a .csv file called A
are the same as in another file .csv B
and print the different cases in a file output.txt? I have done this:
import time
# En primer lugar debemos de abrir el fichero que vamos a leer.
# y abrir el fichero donde vamos a guardar la informacion.
infile = open('Intercambio Modbus v11 - RGA.csv', 'r')
outfile = open("salida.txt","w")
# Mostramos por pantalla lo que leemos desde el fichero
print('>>> Lectura del fichero línea a línea')
# Timer de 2 segundos para probar si funciona, podemos meter timer para que espere unos segundos antes de comprobar una salida.
# time.sleep(2)
for line in infile:
line = line[:-1]
split_line = line.split(";")
if split_line[5] == split_line[11]:
outfile.write("La línea es correcta\n")
#time.sleep(3)
else:
outfile.write("NO COINCIDEN LOS VALORES --> " + line + "\n")
# Cerramos el fichero.
infile.close()
outfile.close()
With this file I check the values that I want to know if they are the same in the same file but ... What happens if instead of split_line[11]
of the same file I would like to check another file? How can I do it?