Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Last active September 28, 2016 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swbuehler/88cd22d4d5f356a7ed168a05f02dfb78 to your computer and use it in GitHub Desktop.
Save swbuehler/88cd22d4d5f356a7ed168a05f02dfb78 to your computer and use it in GitHub Desktop.
Power Query M code to process JSON file from Twitch.tv Import
let
Source = Json.Document(File.Contents("C:\Temp\missellacronin.json")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"created_at", "notifications", "user"}, {"created_at", "notifications", "user"}),
#"Expanded user" = Table.ExpandRecordColumn(#"Expanded Column1", "user", {"_id", "name", "created_at", "updated_at", "display_name", "logo", "bio", "type"}, {"user._id", "user.name", "user.created_at", "user.updated_at", "user.display_name", "user.logo", "user.bio", "user.type"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded user",{{"created_at", type datetimezone}, {"user.created_at", type datetimezone}, {"user.updated_at", type datetimezone}}),
#"Calculated Local Time" = Table.TransformColumns(#"Changed Type",{{"created_at", DateTimeZone.ToLocal, type datetimezone}, {"user.created_at", DateTimeZone.ToLocal, type datetimezone}, {"user.updated_at", DateTimeZone.ToLocal, type datetimezone}}),
#"Sorted Rows" = Table.Sort(#"Calculated Local Time",{{"created_at", Order.Descending}})
in
#"Sorted Rows"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment