Задать вопрос
  • Как сделать правильный цикл назначения одной сущности другой?

    @sergey_frolkin Автор вопроса
    Книги берутся из csv файла:
    Title,Author,Genre,Pages,Publisher
    Fundamentals of Wavelets,"Goswami, Jaideva",signal_processing,228,Wiley
    Data Smart,"Foreman, John",data_science,235,Wiley
    God Created the Integers,"Hawking, Stephen",mathematics,197,Penguin
    Superfreakonomics,"Dubner, Stephen",economics,179,HarperCollins
    Orientalism,"Said, Edward",history,197,Penguin
    "Nature of Statistical Learning Theory, The","Vapnik, Vladimir",data_science,230,Springer
    Integration of the Indian States,"Menon, V P",history,217,Orient Blackswan
    "Drunkard's Walk, The","Mlodinow, Leonard",science,197,Penguin
    Image Processing & Mathematical Morphology,"Shih, Frank",signal_processing,241,CRC
    How to Think Like Sherlock Holmes,"Konnikova, Maria",psychology,240,Penguin


    Юзеры из json:
    {
            "_id": "5e2696e561fdc6df60d43b5f",
            "index": 0,
            "guid": "3e518b31-20f0-4dea-8de8-039af5afbd33",
            "isActive": false,
            "balance": "$3,646.47",
            "picture": "http://placehold.it/32x32",
            "age": 34,
            "eyeColor": "brown",
            "name": "Lolita Lynn",
            "gender": "female",
            "company": "HIVEDOM",
            "email": "lolitalynn@hivedom.com",
            "phone": "+1 (842) 513-2979",
            "address": "389 Neptune Avenue, Belfair, Iowa, 6116",
            "about": "Ea irure labore culpa proident sint cupidatat minim laboris labore eu exercitation aliqua duis aute. Consectetur pariatur commodo enim pariatur mollit. Laborum nisi cillum do consectetur laboris nulla id laboris eu voluptate sit consequat commodo aute. Ad minim eiusmod pariatur non cupidatat esse fugiat et laborum ullamco commodo. Sint fugiat enim elit pariatur consequat ipsum Lorem qui qui Lorem proident mollit culpa. In enim commodo culpa nostrud reprehenderit nostrud incididunt elit labore. Aute proident mollit pariatur proident enim commodo.\r\n",
            "registered": "2014-03-19T10:39:24 -06:00",
            "latitude": 0.246756,
            "longitude": -96.404056,
            "tags": [
                "ad",
                "ut",
                "do",
                "dolor",
                "qui",
                "quis",
                "enim"
            ],
            "friends": [
                {
                    "id": 0,
                    "name": "Joan Weaver"
                },
                {
                    "id": 1,
                    "name": "Morris Wheeler"
                },
                {
                    "id": 2,
                    "name": "Morton Noble"
                }
            ],
            "greeting": "Hello, Lolita Lynn! You have 2 unread messages.",
            "favoriteFruit": "banana"
        },


    Результат (json) как набор списков (количество списков = количеству книг, только в слудующем массиве юзеров книга у второго):
    [
        {
            "name": "Lolita Lynn",
            "gender": "female",
            "address": "389 Neptune Avenue, Belfair, Iowa, 6116",
            "age": 34,
            "books": [
                {
                    "title": "Fundamentals of Wavelets",
                    "author": "Goswami, Jaideva",
                    "pages": "228",
                    "genre": "signal_processing"
                }
            ]
        },
        {
            "name": "Tonia Hurst",
            "gender": "female",
            "address": "917 Terrace Place, Urbana, Idaho, 684",
            "age": 31,
            "books": []
        },
        {
            "name": "Brooks Bright",
            "gender": "male",
            "address": "901 Mermaid Avenue, Wyoming, Marshall Islands, 8506",
            "age": 39,
            "books": []
        },
        {
            "name": "Kathrine Sharp",
            "gender": "female",
            "address": "989 Huron Street, Talpa, Utah, 7018",
            "age": 40,
            "books": []
        },
        {
            "name": "Shawn Harrell",
            "gender": "female",
            "address": "534 Hinsdale Street, Albany, Palau, 3291",
            "age": 34,
            "books": []
        },
        {
            "name": "Amy Casey",
            "gender": "female",
            "address": "589 Townsend Street, Hiseville, Connecticut, 7082",
            "age": 31,
            "books": []
        },
        {
            "name": "Lorena Mejia",
            "gender": "female",
            "address": "614 High Street, Blanford, Maryland, 2776",
            "age": 24,
            "books": []
        },
        {
            "name": "Allyson Wilkins",
            "gender": "female",
            "address": "572 Downing Street, Ivanhoe, American Samoa, 8235",
            "age": 29,
            "books": []
        },
        {
            "name": "Mays Reed",
            "gender": "male",
            "address": "306 Georgia Avenue, Hall, New Mexico, 1402",
            "age": 38,
            "books": []
        },
        {
            "name": "Katherine Mayer",
            "gender": "female",
            "address": "640 Prescott Place, Curtice, Kansas, 3395",
            "age": 27,
            "books": []
        },
        {
            "name": "Kelly Byers",
            "gender": "female",
            "address": "865 Revere Place, Homeland, Arizona, 232",
            "age": 35,
            "books": []
        },
        {
            "name": "Schwartz Carey",
            "gender": "male",
            "address": "860 Centre Street, Hiwasse, Nevada, 2819",
            "age": 32,
            "books": []
        },
        {
            "name": "Kay Beasley",
            "gender": "female",
            "address": "358 Sutton Street, Bellamy, Ohio, 8845",
            "age": 34,
            "books": []
        },
        {
            "name": "Robbins Gordon",
            "gender": "male",
            "address": "610 Langham Street, Boykin, Guam, 6688",
            "age": 23,
            "books": []
        },
        {
            "name": "Hillary Bauer",
            "gender": "female",
            "address": "951 Cumberland Street, Alleghenyville, Oregon, 7073",
            "age": 39,
            "books": []
        },
        {
            "name": "Ruiz Phelps",
            "gender": "male",
            "address": "836 Troutman Street, Harborton, Kentucky, 4030",
            "age": 36,
            "books": []
        },
        {
            "name": "Carolina Bryant",
            "gender": "female",
            "address": "377 Middagh Street, Ellerslie, Nebraska, 2644",
            "age": 31,
            "books": []
        },
        {
            "name": "Sosa Lee",
            "gender": "male",
            "address": "364 Holly Street, Omar, California, 5140",
            "age": 31,
            "books": []
        },
        {
            "name": "Lorna Scott",
            "gender": "female",
            "address": "878 Marconi Place, Gerton, Alabama, 845",
            "age": 24,
            "books": []
        },
        {
            "name": "Bernard Holden",
            "gender": "male",
            "address": "674 Pine Street, Conestoga, Mississippi, 4727",
            "age": 32,
            "books": []
        },
        {
            "name": "Craft Shields",
            "gender": "male",
            "address": "586 Java Street, Catherine, Arkansas, 1445",
            "age": 31,
            "books": []
        },
        {
            "name": "Mara English",
            "gender": "female",
            "address": "324 Herkimer Court, Boomer, Delaware, 5367",
            "age": 23,
            "books": []
        },
        {
            "name": "Fisher Levy",
            "gender": "male",
            "address": "540 Adler Place, Hachita, Federated States Of Micronesia, 9894",
            "age": 30,
            "books": []
        },
        {
            "name": "Cecelia Snyder",
            "gender": "female",
            "address": "236 Anchorage Place, Odessa, Michigan, 6314",
            "age": 25,
            "books": []
        },
        {
            "name": "Nina Kaufman",
            "gender": "female",
            "address": "538 Ashford Street, Boling, West Virginia, 7840",
            "age": 22,
            "books": []
        },
        {
            "name": "Dillard Branch",
            "gender": "male",
            "address": "225 Hampton Avenue, Bethany, Pennsylvania, 8056",
            "age": 37,
            "books": []
        },
        {
            "name": "Dyer Bartlett",
            "gender": "male",
            "address": "880 Meadow Street, Seymour, Puerto Rico, 7921",
            "age": 33,
            "books": []
        },
        {
            "name": "Tyler Dotson",
            "gender": "male",
            "address": "220 Herkimer Place, Turpin, Oklahoma, 4468",
            "age": 20,
            "books": []
        }
    ]
    Написано
  • Как сделать правильный цикл назначения одной сущности другой?

    @sergey_frolkin Автор вопроса
    Vindicar, Симптомы такие что в итоговом файле есть дубли юзеров, условно для каждой книги создаются все 28 юзеров, для второй - те же самые 28 вновь и так далее
    Написано