Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fetching Remove Password comments from Github. Using Power Query and R
let
header = [#"Accept"="application/vnd.github.cloak-preview"],
response = Web.Contents("https://api.github.com/search/commits?q=remove password",[Headers=header]),
json = Json.Document(response),
select = Table.SelectColumns(Table.FromRecords(json[items]),{"url","commit","repository"}),
expand_commit = Table.TransformColumns(Table.ExpandRecordColumn(select, "commit", {"committer", "message"}),{"message",each Text.Clean(_) }),
expand_commiter = Table.ExpandRecordColumn(expand_commit, "committer", {"date", "name", "email"}),
expand_repo = Table.ExpandRecordColumn(expand_commiter, "repository", {"html_url"}),
commits = Table.AddColumn(expand_repo, "commit", each Json.Document(Web.Contents([url]))),
files = Table.ExpandListColumn(Table.ExpandRecordColumn(commits, "commit", {"files"}),"files"),
patches = Table.ExpandRecordColumn(files, "files", {"patch"}),
RScript = R.Execute("temp<-dataset#(lf)pattern<-""(?mi)^-.*""#(lf)temp$replace<-sapply(temp$patch,function(x) toString(regmatches(x, regexpr(pattern, x, perl=TRUE))))",[dataset=patches]),
temp = RScript{[Name="temp"]}[Value],
out = Table.RemoveColumns(temp,{"patch"})
in
out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment