Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Jacky
Frequent Visitor

Execution result in R.Execute (export data to csv file)

Hello Cummunity,

I am trying to export data to csv file in power query as part of the data loading of my model.
I am using :

Source="some table...",
RScript = R.Execute("write.csv(dataset,"C:\\ABCD.csv",[dataset=Source])
in
RScript
when inside the steps of power query, the file is created successfully.
The main issue for me is when the entire model is refreshing the exporting of the table does not work (no file is created).
another thing is that the "RScript" returns an empty table, whereas I want to make sure that the file was properly exported and to have some basic information about the number of record in the file and the time the file was created.
any ideas how I can accomlish that ?

1 ACCEPTED SOLUTION
vcastello
Resolver III
Resolver III

Hi @Jacky

When I want to export a dataset into R I normally use ...

write.table(dataset, file="d:/path1/path2/file.txt", sep="\t", row.names=FALSE)

 


You can check a couple of post by the amazing @ImkeF where she explains ...

1.- how to export data to R

http://www.thebiccountant.com/2015/12/28/how-to-export-data-from-power-bi-and-power-query/

 

2.- Some tips&tricks for dealing with R and Power BI

http://www.thebiccountant.com/2017/08/25/tips-and-tricks-for-r-scripts-in-the-query-editor-in-power-...


If you read this ... thanks @ImkeF

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, Please mention output <- dataset after your script you will get an output as a table.

 

 

let me know if it solved your issue.

 

 

Thanks,

Parul Mishra

vcastello
Resolver III
Resolver III

Hi @Jacky

When I want to export a dataset into R I normally use ...

write.table(dataset, file="d:/path1/path2/file.txt", sep="\t", row.names=FALSE)

 


You can check a couple of post by the amazing @ImkeF where she explains ...

1.- how to export data to R

http://www.thebiccountant.com/2015/12/28/how-to-export-data-from-power-bi-and-power-query/

 

2.- Some tips&tricks for dealing with R and Power BI

http://www.thebiccountant.com/2017/08/25/tips-and-tricks-for-r-scripts-in-the-query-editor-in-power-...


If you read this ... thanks @ImkeF

Anonymous
Not applicable

Hi @Jacky,

 

Try this:

 

require(gdata)
write.table(trim(dataset), file="C:/ABCD.csv", sep = "\t", row.names = FALSE, append = TRUE)
plot(dataset);

source:

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.