Created
March 9, 2017 16:30
-
-
Save Hugoberry/2dbb1a630be38ee7bbbcb9df3148dbb7 to your computer and use it in GitHub Desktop.
Fetching Remove Password comments from Github. Using Power Query and R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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