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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Power BI Desktop adds column to csv files upon refresh

Hi

 

I have a situation where Power BI Desktop adds an extra column upon refreshing the data. The scheduled refresh itself works great.

 

I have some R script in each file that looks like this:

write.csv(dataset, file="S:\[filename].csv")

 

When I edit the query it only shows "Name" and "Value" fields. The original csv file has 10+ columns.

When the refresh occurs I notice that an additional field is added to the beginning of my csv file. It seems to mock a row count.

For now I have to delete the files prior to doing a refresh, otherwise it will keep adding extra columns.

Has anyone else experienced this?

 

2 ACCEPTED SOLUTIONS

Your R-script causes that. Add and additional argument: row.names=FALSE to avoid it.

See here for example about further details: http://rprogramming.net/write-csv-in-r/

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

Anonymous
Not applicable

Thank so much. I have searched for weeks looking for the answer on the web. I couldn't figure out why it was doing that. Cudos!

View solution in original post

3 REPLIES 3
tarunsingla
Solution Sage
Solution Sage

If the column names you need are fixed, then in the query editor, select all the columns you need and remove other columns. That way, any new unwanted additional columns (in subsequent refreshes) are automatically removed.

 

Untitled.png

 

Regards,

Tarun

Your R-script causes that. Add and additional argument: row.names=FALSE to avoid it.

See here for example about further details: http://rprogramming.net/write-csv-in-r/

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Thank so much. I have searched for weeks looking for the answer on the web. I couldn't figure out why it was doing that. Cudos!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.