2
I am having a problem related to lists, I have some files to access and pass them to lists (3 files to 3 lists).
Basically one of the files would have technical data of IBGE, and I need to take this number of his registration and look in another list this string to validate if the technical really exists, You need to do the same for another list that holds the cities where the registrations were made.
I came to take a look related to searching in list with > index
but from what I understand it looks for the first element repeated and shows its position;
I also looked at the if
element in list, however what I wish is to take the registration of the technician (a file) and the city (another file) and search in the search of the IBGE (the third file) if that technician and the city exists, so I would validate and with that I would create statistics according to the response of the staff who answered the survey.
So far I’ve made a simple code with what I’ve learned so far, I can access the files, I can give a split
, to improve the visualization, I know printar
the list elements (the way I did the elements are separated on each line, but it would be preferable to separate them into smaller parts.
Example of how it is now:
'T010;4404;08430-026;6;64;6;4;2;-;4;6;2;-;2;1;1;7;1992;4;1;1\n', 'T011;866;04854-280;1;62;6;1;2;-;10;5;3;-;6;1;2;4;1970;5;2;3\n',
A melhor forma seria algo tipo 'T010;','4404;','08430-026;','6;','64;','6;','4;','2;','-;','4;','6;','2;'...\n',
),
In case I took this '4404
' that would be searched in an archive of regions, that would return me the city if it existed this 4404, it would take the city related to this number and in conjunction with the registration of the technician: 'T010' would search in the research file of the IBGE.
Look at my code so far:
`f = open('exemplopesquisa.txt', 'r')
matrizex=f.readlines()
print(matrizex)
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]
print(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,v)
print(matrizex[0:801])
if
print(len(matrizex))
print(len(line))
if 'T001' in line[0:60]:
print("TUDO OK")
for linha in matrizex:
if 'T001' in linha:
print("ok")`
The files are in this folder: Link to the txt files
Can you clearly place an example of content for each of the files ? Preferably with more than one line
– Isac