IMDB Name Basics


This entry is part 6 of 9 in the series IMDB Data Files

The namebasics file has all of the people in it. It has the moving pictures that they are “known for”.

Below is the M Language listing for the importing of namebasics.tsv. You will need to change the first line’s directory to suit your computer if you plan to copy and paste this script into your project.

let
    Source = Csv.Document(File.Contents("D:\IMDB\namebasics.tsv"),[Delimiter="	", Columns=6, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed all columns to text" = Table.TransformColumnTypes(#"Promoted Headers",{{"nconst", type text}, {"primaryName", type text}, {"birthYear", type text}, {"deathYear", type text}, {"primaryProfession", type text}, {"knownForTitles", type text}}),
    #"Replaced \N with null birthYear" = Table.ReplaceValue(#"Changed all columns to text","\N",null,Replacer.ReplaceValue,{"birthYear"}),
    #"Replaced blanks with null birthYear" = Table.ReplaceValue(#"Replaced \N with null birthYear","",null,Replacer.ReplaceValue,{"birthYear"}),
    #"Replaced \N with null deathYear" = Table.ReplaceValue(#"Replaced blanks with null birthYear","\N",null,Replacer.ReplaceValue,{"deathYear"}),
    #"Replaced blanks with null deathYear" = Table.ReplaceValue(#"Replaced \N with null deathYear","",null,Replacer.ReplaceValue,{"deathYear"}),
    #"Changed birthYear deathYear type to number" = Table.TransformColumnTypes(#"Replaced blanks with null deathYear",{{"birthYear", Int64.Type}, {"deathYear", Int64.Type}}),
    #"Replaced \N with null primaryProfession" = Table.ReplaceValue(#"Changed birthYear deathYear type to number","\N",null,Replacer.ReplaceValue,{"primaryProfession"}),
    #"Replaced blanks with null primaryProfession" = Table.ReplaceValue(#"Replaced \N with null primaryProfession","",null,Replacer.ReplaceValue,{"primaryProfession"}),
    #"Replaced \N with null knownForTitles" = Table.ReplaceValue(#"Replaced blanks with null primaryProfession","\N",null,Replacer.ReplaceValue,{"knownForTitles"}),
    #"Replaced blanks with null knownForTitles" = Table.ReplaceValue(#"Replaced \N with null knownForTitles","",null,Replacer.ReplaceValue,{"knownForTitles"}),
    #"Split primaryProfession into three" = Table.SplitColumn(#"Replaced blanks with null knownForTitles", "primaryProfession", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"primaryProfession.1", "primaryProfession.2", "primaryProfession.3"}),
    #"Changed all primaryProfession to text" = Table.TransformColumnTypes(#"Split primaryProfession into three",{{"primaryProfession.1", type text}, {"primaryProfession.2", type text}, {"primaryProfession.3", type text}}),
    #"Split knownForTitles into four" = Table.SplitColumn(#"Changed all primaryProfession to text", "knownForTitles", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"knownForTitles.1", "knownForTitles.2", "knownForTitles.3", "knownForTitles.4"}),
    #"Changed all knownForTitles to text" = Table.TransformColumnTypes(#"Split knownForTitles into four",{{"knownForTitles.1", type text}, {"knownForTitles.2", type text}, {"knownForTitles.3", type text}, {"knownForTitles.4", type text}})
in
    #"Changed all knownForTitles to text"
Series Navigation<< IMDB Unique Genres QueryIMDB Primary Profession >>

Leave a Reply