Created
March 23, 2017 19:34
-
-
Save jamesperes-zz/a3ce498db2d1b95f644dd7c8a64c1e38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# encoding: iso-8859-1 | |
# encoding: win-1252 | |
import xmltodict as xd | |
import json | |
from limpa import limpa | |
def buscakey(recebe_id): | |
# abre o arquivo completo | |
f = open('keywords.xml', 'r') | |
palavras = f.read() | |
palavras = palavras.decode('iso-8859-1').encode('utf-8') | |
dict_from_xml = xd.parse(palavras) | |
lista = dict_from_xml["pub23DB"]['t_Keyword']['Keyword'] | |
teste = 'a' | |
for i in lista: | |
a = i['KeywordID'] | |
nome = limpa(i['Text']) | |
if a == recebe_id: | |
teste = nome | |
classifica = open('classificacao.json', 'r') | |
classifica_lido = classifica.read() | |
listaeclassifica = json.loads(classifica_lido, encoding='utf-8') | |
for i in listaeclassifica: | |
d = i['fields']['nome'] | |
d = d.lower().encode('utf-8') | |
if d == teste: | |
pk = i['pk'] | |
espec = open('especialidade.json', 'r') | |
espec_lido = espec.read() | |
listaespec = json.loads(espec_lido, encoding='utf-8') | |
for i in listaespec: | |
b = i['fields']['nome'] | |
b = b.lower().encode('utf-8') | |
if b == teste: | |
pk = i['pk'] | |
topog = open('topografia.json', 'r') | |
topog_lido = topog.read() | |
listatopog = json.loads(topog_lido, encoding='utf-8') | |
for i in listatopog: | |
t = i['fields']['nome'] | |
t = t.lower().encode('utf-8') | |
if t == teste: | |
pk = i['pk'] | |
return pk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment