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 | |
| Source = Csv.Document(File.Contents("RTwitterSample.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.Csv]), | |
| twitts = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), | |
| RScript = R.Execute("temp<-dataset#(lf)pattern<-""[#@]\\w+""#(lf)temp$mention<-sapply(temp$text,function(x) toString(regmatches(x, regexpr(pattern, x))))",[dataset=twitts ]), | |
| out = RScript{[Name="temp"]}[Value] | |
| in | |
| out |
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 | |
| RScript = R.Execute("datacsv<-read.csv(unz(""d:\\Downloads\\R_Twitter_sample.zip"",""R_Twitter_sample.csv""))"), | |
| out = RScript{[Name="datacsv"]}[Value] | |
| in | |
| out |
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 | |
| seed = {1..10000000}, | |
| seedTable = Table.FromList(seed, Splitter.SplitByNothing(), null, null, ExtraValues.Error), | |
| RScript = R.Execute("write.csv(dataset,""d:\\Downloads\\out.csv"")",[dataset=seedTable]), | |
| out = RScript | |
| in | |
| out |
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 | |
| RScript = R.Execute("output <- read.table(text=system2(""whoami"", stdout=TRUE))"), | |
| output = RScript{[Name="output"]}[Value] | |
| in | |
| output |
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
| ##Get msmdsrv process details | |
| msmdsrv_proc <- system2("tasklist",args = c('/fi','"imagename eq msmdsrv.exe"'), stdout=TRUE) | |
| msmdsrv_clean<-msmdsrv_proc[-c(1,3)] | |
| msmdsrv<-read.fwf(textConnection(msmdsrv_clean),widths=c(25,9,17,12,13),comment.char="") | |
| ##Get all TCP ports | |
| tcp <- system2("netstat", args = c('-anop','TCP'), stdout=TRUE) | |
| ports<-read.fwf(textConnection(tcp),skip=3,widths=c(9,23,23,16,10)) |
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 | |
| RScript = R.Execute("msmdsrv_proc <- system2(""tasklist"",args = c('/fi','""imagename eq msmdsrv.exe""'), stdout=TRUE) #(lf)msmdsrv_clean<-msmdsrv_proc[-c(1,3)]#(lf)msmdsrv<-read.fwf(textConnection(msmdsrv_clean),widths=c(25,9,17,12,13),comment.char="""")#(lf)tcp <- system2(""netstat"", args = c('-anop','TCP'), stdout=TRUE)#(lf)ports<-read.fwf(textConnection(tcp),skip=3,widths=c(9,23,23,16,10))"), | |
| formatTable = (T) => Table.PromoteHeaders(Table.TransformColumns(T,{{"V1",Text.Trim},{"V2",Text.Trim},{"V3",Text.Trim},{"V4",Text.Trim},{"V5",Text.Trim}})), | |
| msmdsrv = formatTable(RScript{[Name="msmdsrv"]}[Value]), | |
| ports = formatTable(RScript{[Name="ports"]}[Value]), | |
| match = Table.SelectRows(ports, each [PID]=Table.ToRecords(msmdsrv){0}[PID]){0}[Local Address], | |
| out = List.Last(Text.Split(match,":")) | |
| in | |
| out |
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 | |
| //Assume current user is the one with latest [Date accessed] folder in C:\Users | |
| CurrentUser = Table.FirstN( | |
| Table.Sort(Folder.Contents("C:\Users"), | |
| {{"Date accessed", Order.Descending}}), | |
| 1)[Name]{0}, | |
| //Read the contents of file msmdsrv.port.txt from subfolder of AnalysisServicesWorkspaces | |
| Port = Lines.FromBinary( | |
| Table.SelectRows( |
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
| #Finding the portnumber on which the $Embedded$ tabular model is running on | |
| $embedded = "$env:LOCALAPPDATA\Microsoft\Power BI Desktop\AnalysisServicesWorkspaces" | |
| $ports = Get-ChildItem $embedded -rec | where {$_.Name -eq "msmdsrv.port.txt"} | |
| $port = Get-Content $ports.FullName -Encoding Unicode | |
| #Getting the data sources from the $Embedded$ tabular model | |
| [xml] $db = Invoke-ASCmd -Server:localhost:$port -Query:"SELECT * from `$SYSTEM.TMSCHEMA_DATA_SOURCES" | |
| $db.return.root.row | |
| $cs = $db.return.root.row.ConnectionString |
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
| (port as text) => | |
| let | |
| //Get $Embedded$ database name | |
| catalog = AnalysisServices.Databases("localhost:"&port)[Name]{0}, | |
| //Run DMV query to get data source details | |
| dataSources = AnalysisServices.Database("localhost:"&port,catalog, | |
| [Query="select * from $system.TMSCHEMA_DATA_SOURCES"]) | |
| in | |
| dataSources[ConnectionString]{0} |
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
| (connectionString as text) => | |
| let | |
| //Define a semicolon splitter | |
| split = Splitter.SplitTextByDelimiter(";"), | |
| //Split the connection string by semicaolon and assume that Mashup is the last element | |
| mashup = Text.Replace(List.Last(split(connectionString)),"Mashup=","") | |
| in | |
| //Convert base64 string to binary | |
| Binary.FromText(mashup) |