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
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
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.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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