メイン コンテンツをスキップする 補完的コンテンツへスキップ

フラットストラクチャーから階層マップストラクチャーを作成

この機能によって、既存のフラットストラクチャーに基づいて階層ストラクチャーを作成して自動で一緒にマップできるようになります。

始める前に

フラットストラクチャーを作成済みであること。

このタスクについて

この例では、1990年から2016年の間にオスカーを受賞した男優と女優の情報が含まれているCSVファイルを入力として使います。変換の目的は、データがまず年別にグループ化され、次に映画別にグループ化されたJSONファイルを取得することです。各映画のレコードには、その映画でオスカーを受賞した俳優の配列が含まれることになります。

入力用のCSVファイルは次のデータから作成できます。
Index,Gender,Year,Age,Name,Movie
1,female,1990,80,Jessica Tandy,Driving Miss Daisy
2,female,1991,42,Kathy Bates,Misery
3,female,1992,29,Jodie Foster,The Silence of the Lambs
4,female,1993,33,Emma Thompson,Howards End
5,female,1994,36,Holly Hunter,The Piano
6,female,1995,45,Jessica Lange,Blue Sky
7,female,1996,49,Susan Sarandon,Dead Man Walking
8,female,1997,39,Frances McDormand,Fargo
9,female,1998,34,Helen Hunt,As Good as It Gets
10,female,1999,26,Gwyneth Paltrow,Shakespeare in Love
11,female,2000,25,Hilary Swank,Boys Don't Cry
12,female,2001,33,Julia Roberts,Erin Brockovich
13,female,2002,35,Halle Berry,Monster's Ball
14,female,2003,35,Nicole Kidman,The Hours
15,female,2004,28,Charlize Theron,Monster
16,female,2005,30,Hilary Swank,Million Dollar Baby
17,female,2006,29,Reese Witherspoon,Walk the Line
18,female,2007,61,Helen Mirren,The Queen
19,female,2008,32,Marion Cotillard,La Vie en rose
20,female,2009,33,Kate Winslet,The Reader
21,female,2010,45,Sandra Bullock,The Blind Side
22,female,2011,29,Natalie Portman,Black Swan
23,female,2012,62,Meryl Streep,The Iron Lady
24,female,2013,22,Jennifer Lawrence,Silver Linings Playbook
25,female,2014,44,Cate Blanchett,Blue Jasmine
26,female,2015,54,Julianne Moore,Still Alice
27,female,2016,26,Brie Larson,Room
28,male,1990,32,Daniel Day-Lewis,My Left Foot
29,male,1991,42,Jeremy Irons,Reversal of Fortune
30,male,1992,54,Anthony Hopkins,The Silence of the Lambs
31,male,1993,52,Al Pacino,Scent of a Woman
32,male,1994,37,Tom Hanks,Philadelphia
33,male,1995,38,Tom Hanks,Forrest Gump
34,male,1996,32,Nicolas Cage,Leaving Las Vegas
35,male,1997,45,Geoffrey Rush,Shine
36,male,1998,60,Jack Nicholson,As Good as It Gets
37,male,1999,46,Roberto Benigni,Life Is Beautiful
38,male,2000,40,Kevin Spacey,American Beauty
39,male,2001,36,Russell Crowe,Gladiator
40,male,2002,47,Denzel Washington,Training Day
41,male,2003,29,Adrien Brody,The Pianist
42,male,2004,43,Sean Penn,Mystic River
43,male,2005,37,Jamie Foxx,Ray
44,male,2006,38,Philip Seymour Hoffman,Capote
45,male,2007,45,Forest Whitaker,The Last King of Scotland
46,male,2008,50,Daniel Day-Lewis,There Will Be Blood
47,male,2009,48,Sean Penn,Milk
48,male,2010,60,Jeff Bridges,Crazy Heart
49,male,2011,50,Colin Firth,The King's Speech
50,male,2012,39,Jean Dujardin,The Artist
51,male,2013,55,Daniel Day-Lewis,Lincoln
52,male,2014,44,Matthew McConaughey,Dallas Buyers Club
53,male,2015,33,Eddie Redmayne,The Theory of Everything
54,male,2016,41,Leonardo DiCaprio,The Revenant

手順

  1. マッピングパースペクティブのData Mapperタブで、[Hierarchical Mapper] (階層マッパー)[Maps] (マップ)を右クリックし、[New] (新規) > [Map] (マップ)の順にクリックします。
  2. [Flat to hierarchical map] (フラットマッピングから階層マッピングへ)を選択して[Next] (次へ)をクリックします。
  3. フォルダーを選択し、マップの名前を入力して[Next] (次へ)をクリックします。
  4. フラットな入力ストラクチャーを選択して[Next] (次へ)をクリックします。
  5. フォルダーを選択し、新しいストラクチャーの名前を入力し、[Next] (次へ)をクリックします。
    出力ストラクチャーのエディターが開きます。デフォルトでは、出力ストラクチャーは入力ストラクチャーと同じです。これからカスタマイズしていきます。
  6. 出力ストラクチャーを編集して階層を作成します。
    利用可能な機能の詳細は、階層出力ストラクチャーエディターをご覧ください。
    1. rowエレメントを2回クリックし、Oscarsという名前に変更します。
    2. Oscarsを右クリックし、[Convert to GroupBy] (GroupByに変換)をクリックします。
      デフォルトでは、ループは最初の子エレメント別にグループ化されます。
    3. Yearを右クリックし、[Select as GroupBy element] (GroupByエレメントとして選択)をクリックして、Oscarsループを年別にグループ化します。
    4. Indexエレメントは必要ないので、右クリックして[Delete] (削除)をクリックします。
    5. Movieを右クリックし、[Add GroupBy] (GroupBy)をクリックして、映画別にグループ化されている新しいループを作成します。
    6. NameGenderAgeというエレメントを選択して右クリックし、[Add Record] (レコードを追加)をクリックします。このレコードにActorという名前を付けて[OK]をクリックします。
      これによって、選択されたエレメントが含まれている新しいレコードが作成されます。レコード内のエレメントは、ドラッグ&ドロップで順序を変えることができます。
    7. Actorエレメントを右クリックし、[Add Array] (配列を追加)をクリックして、この配列の名前をActorsに変更します。
    8. MovieループにActors配列をドラッグ&ドロップします。
    9. Movie_groupbyエレメントの名前をMoviesに変更します。
    ストラクチャーは次のようになります。
  7. 編集が終わったら[Finish] (完了)をクリックします。

タスクの結果

マップが生成されます。出力エレメントをクリックすれば、生成された式を確認できます。
[Test Run] (テスト実行)をクリックして出力をプレビューします。この例での出力は次のようになります。
{
    "Oscars": [
        {
            "Year": "1990",
            "Movies": [
                {
                    "Movie": "Driving Miss Daisy",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jessica Tandy",
                                "Gender": "female",
                                "Age": "80"
                            }
                        }
                    ]
                },
                {
                    "Movie": "My Left Foot",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Daniel Day-Lewis",
                                "Gender": "male",
                                "Age": "32"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1991",
            "Movies": [
                {
                    "Movie": "Misery",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Kathy Bates",
                                "Gender": "female",
                                "Age": "42"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Reversal of Fortune",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jeremy Irons",
                                "Gender": "male",
                                "Age": "42"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1992",
            "Movies": [
                {
                    "Movie": "The Silence of the Lambs",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jodie Foster",
                                "Gender": "female",
                                "Age": "29"
                            }
                        },
                        {
                            "Actor": {
                                "Name": "Anthony Hopkins",
                                "Gender": "male",
                                "Age": "54"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1993",
            "Movies": [
                {
                    "Movie": "Howards End",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Emma Thompson",
                                "Gender": "female",
                                "Age": "33"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Scent of a Woman",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Al Pacino",
                                "Gender": "male",
                                "Age": "52"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1994",
            "Movies": [
                {
                    "Movie": "Philadelphia",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Tom Hanks",
                                "Gender": "male",
                                "Age": "37"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Piano",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Holly Hunter",
                                "Gender": "female",
                                "Age": "36"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1995",
            "Movies": [
                {
                    "Movie": "Blue Sky",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jessica Lange",
                                "Gender": "female",
                                "Age": "45"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Forrest Gump",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Tom Hanks",
                                "Gender": "male",
                                "Age": "38"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1996",
            "Movies": [
                {
                    "Movie": "Dead Man Walking",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Susan Sarandon",
                                "Gender": "female",
                                "Age": "49"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Leaving Las Vegas",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Nicolas Cage",
                                "Gender": "male",
                                "Age": "32"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1997",
            "Movies": [
                {
                    "Movie": "Fargo",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Frances McDormand",
                                "Gender": "female",
                                "Age": "39"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Shine",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Geoffrey Rush",
                                "Gender": "male",
                                "Age": "45"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1998",
            "Movies": [
                {
                    "Movie": "As Good as It Gets",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Helen Hunt",
                                "Gender": "female",
                                "Age": "34"
                            }
                        },
                        {
                            "Actor": {
                                "Name": "Jack Nicholson",
                                "Gender": "male",
                                "Age": "60"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "1999",
            "Movies": [
                {
                    "Movie": "Life Is Beautiful",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Roberto Benigni",
                                "Gender": "male",
                                "Age": "46"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Shakespeare in Love",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Gwyneth Paltrow",
                                "Gender": "female",
                                "Age": "26"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2000",
            "Movies": [
                {
                    "Movie": "American Beauty",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Kevin Spacey",
                                "Gender": "male",
                                "Age": "40"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Boys Don't Cry",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Hilary Swank",
                                "Gender": "female",
                                "Age": "25"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2001",
            "Movies": [
                {
                    "Movie": "Erin Brockovich",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Julia Roberts",
                                "Gender": "female",
                                "Age": "33"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Gladiator",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Russell Crowe",
                                "Gender": "male",
                                "Age": "36"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2002",
            "Movies": [
                {
                    "Movie": "Monster's Ball",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Halle Berry",
                                "Gender": "female",
                                "Age": "35"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Training Day",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Denzel Washington",
                                "Gender": "male",
                                "Age": "47"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2003",
            "Movies": [
                {
                    "Movie": "The Hours",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Nicole Kidman",
                                "Gender": "female",
                                "Age": "35"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Pianist",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Adrien Brody",
                                "Gender": "male",
                                "Age": "29"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2004",
            "Movies": [
                {
                    "Movie": "Monster",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Charlize Theron",
                                "Gender": "female",
                                "Age": "28"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Mystic River",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Sean Penn",
                                "Gender": "male",
                                "Age": "43"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2005",
            "Movies": [
                {
                    "Movie": "Million Dollar Baby",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Hilary Swank",
                                "Gender": "female",
                                "Age": "30"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Ray",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jamie Foxx",
                                "Gender": "male",
                                "Age": "37"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2006",
            "Movies": [
                {
                    "Movie": "Capote",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Philip Seymour Hoffman",
                                "Gender": "male",
                                "Age": "38"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Walk the Line",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Reese Witherspoon",
                                "Gender": "female",
                                "Age": "29"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2007",
            "Movies": [
                {
                    "Movie": "The Queen",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Helen Mirren",
                                "Gender": "female",
                                "Age": "61"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Last King of Scotland",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Forest Whitaker",
                                "Gender": "male",
                                "Age": "45"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2008",
            "Movies": [
                {
                    "Movie": "La Vie en rose",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Marion Cotillard",
                                "Gender": "female",
                                "Age": "32"
                            }
                        }
                    ]
                },
                {
                    "Movie": "There Will Be Blood",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Daniel Day-Lewis",
                                "Gender": "male",
                                "Age": "50"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2009",
            "Movies": [
                {
                    "Movie": "Milk",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Sean Penn",
                                "Gender": "male",
                                "Age": "48"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Reader",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Kate Winslet",
                                "Gender": "female",
                                "Age": "33"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2010",
            "Movies": [
                {
                    "Movie": "Crazy Heart",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jeff Bridges",
                                "Gender": "male",
                                "Age": "60"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Blind Side",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Sandra Bullock",
                                "Gender": "female",
                                "Age": "45"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2011",
            "Movies": [
                {
                    "Movie": "Black Swan",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Natalie Portman",
                                "Gender": "female",
                                "Age": "29"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The King's Speech",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Colin Firth",
                                "Gender": "male",
                                "Age": "50"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2012",
            "Movies": [
                {
                    "Movie": "The Artist",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jean Dujardin",
                                "Gender": "male",
                                "Age": "39"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Iron Lady",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Meryl Streep",
                                "Gender": "female",
                                "Age": "62"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2013",
            "Movies": [
                {
                    "Movie": "Lincoln",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Daniel Day-Lewis",
                                "Gender": "male",
                                "Age": "55"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Silver Linings Playbook",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Jennifer Lawrence",
                                "Gender": "female",
                                "Age": "22"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2014",
            "Movies": [
                {
                    "Movie": "Blue Jasmine",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Cate Blanchett",
                                "Gender": "female",
                                "Age": "44"
                            }
                        }
                    ]
                },
                {
                    "Movie": "Dallas Buyers Club",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Matthew McConaughey",
                                "Gender": "male",
                                "Age": "44"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2015",
            "Movies": [
                {
                    "Movie": "Still Alice",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Julianne Moore",
                                "Gender": "female",
                                "Age": "54"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Theory of Everything",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Eddie Redmayne",
                                "Gender": "male",
                                "Age": "33"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Year": "2016",
            "Movies": [
                {
                    "Movie": "Room",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Brie Larson",
                                "Gender": "female",
                                "Age": "26"
                            }
                        }
                    ]
                },
                {
                    "Movie": "The Revenant",
                    "Actors": [
                        {
                            "Actor": {
                                "Name": "Leonardo DiCaprio",
                                "Gender": "male",
                                "Age": "41"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

このページは役に立ちましたか?

このページまたはコンテンツにタイポ、ステップの省略、技術的エラーなどの問題が見つかった場合はお知らせください。