I am trying to do a search filter of a tsv file, where the user enters the filters to visualize the data he wants to iterate over the file. The code that I am using is the following:
import csv
with open("results.tsv") as tsvF:
reader = csv.reader(tsvF, delimiter='\t')
encabezado = next(reader)
print(encabezado)
for indice, col_enc in enumerate(encabezado):
print(indice, col_enc)
yearini = input("Desde el año: ")
years, magnitudes, locations = [],[],[]
for col in reader:
year = col[2]
if year > yearini:
years.append(year)
magnitud = float(col[9])
magnitudes.append(magnitud)
location = col[19]
locations.append(location)
for ind in range(0, len(years)):
print(years[ind], ":", magnitudes[ind], '-', locations[ind])
magini = input("Desde :")
years, magnitudes, locations = [],[],[]
for col in reader:
magnitud = col[9]
if magini > magnitud:
magnitudes.append(magnitud)
year = float(col[2])
years.append(year)
loation = col[19]
locations.append(location)
for ind in range(0, len(years)):
print(magnitudes[ind], ":", years[ind], '-', locations[ind])
With this code, the first print(years[ind], ":", magnitudes[ind], '-', locations[ind])
if it works but in the same print
of the last cycle does not show me the data as it does the first.