My question is the following, I must order a file so that the dates or the years are as follows (the file has more than 100,000 records)
Año=1999
Sala1=123
Sala2=341
Sala3=541
(and it would be the same with 2000)
The format given by the file is the following:
Superman-2006-4
Where the last number is the room (4) and then we have the year (2006), how should I search the file for all those with the same date (previously I took the date and room of all) and then add them so that do they look good on me?
Part of the code to get date and room:
archivo=open("Peliculas.txt","rt")
leer=archivo.readline()
mayor=0
menor=1996#esto es ya con el año sacado
cont=0
cont2=0
Sala1,Sala2,Sala3,Sala4,Sala5=0,0,0,0,0
while leer:# ACA BUSCO EL MENOR AÑO Y EL MAYOR AÑO PARA PODER ASI ORDENAR EL ARCHIVO
cont+=1
controlar=leer[::-1]
poner_print=controlar[:7]#por aca hay algun error que me caga en la ultima linea, revisarlo
poner_print=poner_print[::-1]#error solucionado con el cont que para en la linea 49 porque en la 50 surge un error
Año1=poner_print[:4]
Sala1=poner_print[5:]
if int(Año1)>mayor:
mayor=int(Año1)#saque el año aca
if int(Año1)<menor and cont!=49:
menor=int(Año1)#saque el menor año
leer=archivo.readline()
print("El año mas grande fue" ,mayor)
print("El año mas chico fue" ,menor)
In this case, the example I did to make it quick was 50 lines (the file)