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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Kryz82
Regular Visitor

Issue with R as datasource

0

rawdata <- list.files(path = "C:/User/Sample/", pattern = "*.csv", full.names = TRUE)%>% lapply(read_csv)%>% bind_rows

Having issue with this script when using R as data source in Power BI. When there are only 2 csv's in the catalogue, script is running fine, however when there are 3 or more csv files, script is stopping and keeps "Evaluating".

I know the workaround is to read all csv's individually, but that is defying the purpose of reading whole folder.

Other solution is to write csv and import do Power BI as data source, but that again is adding an extra step.

Any ideas?

So far my only solutions were to run script in R and then import csv as data source, my other working solution was to use read.csv for each file and then bind_rows

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Kryz82 ,

Please make sure that all files have identical column names, order, and data types first, then update the scripts as below to load the files:

files <- list.files(path = "C:/User/Sample/", pattern = "\\.csv$", full.names = TRUE)
rawdata <- NULL
for (f in files) {
  tmp <- read.csv(f, stringsAsFactors = FALSE)
  rawdata <- if (is.null(rawdata)) tmp else rbind(rawdata, tmp)
}

Or you can refer the following link to get it:

How can I import multiple csv files into R

 

Besides that, you can connect to "Folder" connector as an alternative:

How To Load Multiple Files Into Power BI 

vyiruanmsft_0-1740639713291.png

Import data from a folder with multiple files (Power Query) - Microsoft Support

Import multiple files from multiple folders, and "... - Microsoft Fabric Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Kryz82 ,

Please make sure that all files have identical column names, order, and data types first, then update the scripts as below to load the files:

files <- list.files(path = "C:/User/Sample/", pattern = "\\.csv$", full.names = TRUE)
rawdata <- NULL
for (f in files) {
  tmp <- read.csv(f, stringsAsFactors = FALSE)
  rawdata <- if (is.null(rawdata)) tmp else rbind(rawdata, tmp)
}

Or you can refer the following link to get it:

How can I import multiple csv files into R

 

Besides that, you can connect to "Folder" connector as an alternative:

How To Load Multiple Files Into Power BI 

vyiruanmsft_0-1740639713291.png

Import data from a folder with multiple files (Power Query) - Microsoft Support

Import multiple files from multiple folders, and "... - Microsoft Fabric Community

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

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.