def get_geo_from_dadata():
    api_key = "Тут секретный API ключ"
    secret_key = "Тут секретный ключ"

    dadata = Dadata(api_key, secret_key)

    counter, good, error = 0, 0, 0
    file_path = 'address.txt'

    with open(file_path, 'r') as file:

        for row in file:
            print('-' * 50)
            print(f'№ {counter}')
            print('address = ', row)
            try:
                result = dadata.clean(name="address",
                                      source="москва сухонская 11")
                print('lat = ', result['geo_lat'])
                print('lng = ', result['geo_lon'])
                good += 1
            except Exception as e:
                error += 1
                print('Не распознан')

            counter += 1

    print('===== Результат =====')
    print(
        f'Всего записей = {counter} \n Распознано = {good} \n Не распознано {error}'
    )

    dadata.close()
Ejemplo n.º 2
0
 def get_address_code(cls, address):
     token = settings.DADATA_TOKEN
     secret = settings.DADATA_SECRET_KEY
     dadata = Dadata(token, secret)
     data = dadata.clean("address", address)
     result = (data.get('geo_lat'), data.get('geo_lon'))
     return result
def get_gender(full_name):
    token = "f1f65baffababb3c9a5f1f89303aa95b671a10a3"
    secret = "0123b896ae0502c432e990444e0dd1a8b4eb8923"
    dadata = Dadata(token, secret)
    result = dadata.clean("name", full_name)
    return result['gender']