Exemple #1
0
import csv
from rldd.client import Client
from rldd import config

dps = Client(config.DPS, 'dps').connect()["persons"]
db = Client(config.PROD).connect()
res_file = open('data.csv', 'w+')
iteration = 0
with open('data2.csv') as csv_file:
    file = csv.reader(csv_file, delimiter=',')
    for row in file:
        iteration += 1
        personId = row[2]
        person = dps.find_one({"_id": Client.getId(personId)})

        print(iteration, personId)
    else:
        return ''


fields = [
    'ФИО', 'Телефоны', 'Почта', 'Дата рождения', 'ДУЛ Серия', 'ДУЛ Номер',
    'Адрес регистрации', 'Адрес проживания', 'Номера заявок',
    'Дата создания заявления', 'Наименование процедуры'
    'Номера автомобиля'
]

result_file = open('result_file.csv', 'w+')
result_file.write(f'{";".join(fields)}\n')
for person_id in persons_list:

    person = persons.find_one({"_id": Client.getId(person_id)})

    if not person:
        continue

    reg_address = getAddress(checkValue(
        person, 'registrationAddressId')) if checkValue(
            person, 'registrationAddressId') != '' else ''
    loc_address = getAddress(
        checkValue(person, 'locationAddressId')) if checkValue(
            person, 'locationAddressId') != '' else ''

    result = {
        'fio': getFio(person),
        "phone": get_contact(person, "MBT", "PHN"),
        "email": get_contact(person, "EML"),