0
I have a problem, I have 3 files that I need to open and get information from them, move to a list within the list (matrix?!) and compare information from 2 lists with another list to validate something. One of the files (that of technicians) holds registrations of technicians, another (regions) holds cities where IBGE surveys took place and the last is the file of the IBGE survey, i have to know if all the technicians that are in the IBGE research archive exist in the technicians archive and if the cities that are in the research archive exist in the regions archive that store all the cities that there was the research. I can pass the information to a "matrix", and compare the information however, I am comparing the lists but there is a part of my code that gives this error: Indexerror: list index out of range I could not see anything wrong so far in this, I have modified several times, put conditions (these conditions I put relates to the files, I basically made matched some things so that did not exceed the range of the files) but the error persists. This is my code:
pesquisa = []
arq_pesq = open('Pesquisa.txt', 'r')
matrizex=arq_pesq.readlines()
for line in matrizex[:]:
#Separa a string por ;
Type = line.split(";")
a = Type[0]
b = Type[1]
c = Type[2]
d = Type[3]
e = Type[4]
f = Type[5]
g = Type[6]
h = Type[7]
i = Type[8]
j = Type[9]
k = Type[10]
l = Type[11]
m = Type[12]
n = Type[13]
o = Type[14]
p = Type[15]
q = Type[16]
r = Type[17]
s = Type[18]
t = Type[19]
v= Type[20]
for i in range(1):
linha = []
for j in range(1):
linha.append(Type)
pesquisa.append(linha)
tecnicos=[]
arquivo_tec=open("tecnicosIBGE.txt" , 'r')
linhas=arquivo_tec.readlines()
for line in linhas[:]:
#Separa a string por ;
Type = line.split(";")
a = Type[0]
b = Type[1]
c = Type[2]
d = Type[3]
for i in range(1):
linha = []
for j in range(1):
linha.append(Type)
tecnicos.append(linha)
erros=[]
n=200
c=142
contador=1
print(tecnicos[n][0][0])
print(pesquisa[c][0][0])
while True:
n=200
c=c-1
contador=1
while(c!=0 or n!=0):
if(c==0):
break
#O erro indica essa próxima linha
elif tecnicos[n][0][0] in pesquisa[c][0][0]:
print("Achou")
print(tecnicos[n][0][0])
print(pesquisa[c][0][0])
n=200
break
else:
if n==0:
erros=pesquisa[c].append
#del(pesquisa[c])
break
n=n-1
if n==0:
break
contador=contador+1
print(tecnicos[n][0][0])
print(pesquisa[c][0][0])
print("Não achou ",contador)