Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
Trying to run a Power BI desktop export to CSV using an R script.
Input data is a csv which i do some transformations on.
let
Source = Csv.Document(File.Contents("C:\Users\jacksparrow\Desktop\NewFiles\Qa-Data-Set-11---Abandoned-Applicants---Filled-2020-09-21.csv"),[Delimiter=",", Columns=12, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Split Column by Delimiter" = Table.SplitColumn(#"Promoted Headers", "Job Status: FILLED Date", Splitter.SplitTextByDelimiter("T", QuoteStyle.Csv), {"Job Status: FILLED Date.1", "Job Status: FILLED Date.2"}),
#"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"Job Status: FILLED Date.1", "Job Status: FILLED Date"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Job Status: FILLED Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DaysSinceFilled", each DateTime.LocalNow()),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"DaysSinceFilled", type date}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"DaysSinceFilled", "Today"}}),
#"Added Custom1" = Table.AddColumn(#"Renamed Columns1", "Custom", each Duration.Days([Today]- [#"Job Status: FILLED Date"])),
THat is before the R script step.
Next i input the following for the R script :
write.csv('dataset',"C:\\Users\\jacksparrow\\Desktop\\test.csv" )
It then adds the above line for Pwer Query
#"Run R script" = R.Execute("write.csv('dataset',""C:\\Users\\jacksparrow\\Desktop\\test.csv"" )",[dataset=#"Added Custom1"])
in
#"Run R script"
But the output CSV it creates, is blank and has just these two lines
x
1 dataset
Just remove the single quotes, it should be dataset not 'dataset'. Also, replace \\ with /.
In query editor, click transform, click Run R script, then in the pop-up windown enter the code below:
write.csv(dataset,"C:/Users/jacksparrow/Desktop/test.csv")
What happens when you run your script in R Studio?
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
103 | |
98 | |
98 | |
38 | |
37 |
User | Count |
---|---|
154 | |
120 | |
73 | |
73 | |
63 |