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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

R auto save issue

Hi everyone, I have an issue in adding the below to my query steps.

 

write.csv(dataset, file = "C:/Users/XXXX/Desktop/dataset.csv")

 

whenever I run it, it displays another empty table with column names Name and Value.

 

 

Here's the query if it will help 🙂 let Source = Excel.Workbook(File.Contents("\\USMFXXXXXL1C\DataAll\WeekID.xlsx"), null, true), WeekIndex_Table = Source{[Item="WeekIndex",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(WeekIndex_Table,{{"Week Ending DATE", type date}, {"Week Number", Int64.Type}, {"Hours", Int64.Type}}), #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)require('gdata')#(lf)write.csv(dataset, file = ""C:/Users/XXXXX/Desktop/dataset.csv"")",[dataset=#"Changed Type"]) in #"Run R script"

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

Could you please tell me whether your problem has been solved?

The R script you wrote is just used to export data to the desktop as a csv. 

After running this R script, it will display another empty table with name and value columns in the edit query, which is the normal result.

26.png

You only need to check whether it generates a csv file which contains the   result you want  on the desktop . 

28.png

 

If the exported date format is incorrect, please convert the date format to text in query editor.

27.png

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

I suggest you to try below solution to use function "write.table" instead of "write.csv":

https://community.powerbi.com/t5/Desktop/Execution-result-in-R-Execute-export-data-to-csv-file/td-p/249296

If help ,you  can also refer to this post.

https://stackoverflow.com/questions/43120853/how-to-save-result-of-r-script-in-power-bi?noredirect=1&lq=1

 

Best regards,

Eason 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors