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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
ChenChristyYu
Helper II
Helper II

Pull data in from folder

Hi Experts,

 

I am pulling data from a big folder, the folder is made up of smaller folders. Each smaller folder contains about 500 PDF file, I tried a folder pull, but instead of pulling in everything, I only want to pull in the name of the PDF files (no contents and others).  It ran very very slow. What can I do?

 

 

Thanks very much.

 

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey

this little R script

sourcePath <- "c:/windows"
files <- data.frame(files = list.files(path = sourcePath, full.names = TRUE, recursive = TRUE))

returns 170000 full-filenames within 28sec on my laptop.

 

Maybe you can use an R script as a datasource, you just have extract the "filename" from the fullname 🙂

 

I guess these links will get you started with R and Power BI 🙂

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Hi Tom, 

 

I am trying to get it work using your way.

 

I input 

sourcePath <- "\\ChinaBusinessReports\BusinessReports\China\201803"
files <- data.frame(files = list.files(path = sourcePath, full.names = TRUE, recursive = TRUE))

 but got this error message

Details: "ADO.NET: R script error.
Error: '\B' is an unrecognized escape in character string starting ""\\ChinaBusinessReports\B"
Execution halted"

 

I am new to this. I looked at other sources, but have not found any clue solving this. Do you have any insight? Thank you so much.

 

Best,

Chen

View solution in original post

6 REPLIES 6
TomMartens
Super User
Super User

Hey

this little R script

sourcePath <- "c:/windows"
files <- data.frame(files = list.files(path = sourcePath, full.names = TRUE, recursive = TRUE))

returns 170000 full-filenames within 28sec on my laptop.

 

Maybe you can use an R script as a datasource, you just have extract the "filename" from the fullname 🙂

 

I guess these links will get you started with R and Power BI 🙂

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom, 

 

I am trying to get it work using your way.

 

I input 

sourcePath <- "\\ChinaBusinessReports\BusinessReports\China\201803"
files <- data.frame(files = list.files(path = sourcePath, full.names = TRUE, recursive = TRUE))

 but got this error message

Details: "ADO.NET: R script error.
Error: '\B' is an unrecognized escape in character string starting ""\\ChinaBusinessReports\B"
Execution halted"

 

I am new to this. I looked at other sources, but have not found any clue solving this. Do you have any insight? Thank you so much.

 

Best,

Chen

Using R means you have to use „/„ (the forward slash) instead of „\“ (the backslash) 😉

Not sure if double \\ will work

I assume you have installed to your local machine.

Regards
Tom


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

I have installed it and set up the r script option in Powerbi. I have been stuck on the Connecting process for a long time and have not been moving on from there.

Hey @ChenChristyYu,

 

here you will find a little word doument that describes the steps to use a R script as a data.source in more detail and here is the pbix file

 

To verify your setup, run this R script in your R ide and make sure that the variable files contains reasonable values and is of type data.frame by using the command str(files).

sourcePath <- "c:/windows"
files <- data.frame(files = list.files(path = sourcePath, full.names = TRUE, recursive = TRUE))

Hope this gets your issue fixed.

 

Regards

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Greg_Deckler
Community Champion
Community Champion

Something similar to this came up before in another thread. Not sure that Power BI is the right tool for this, I would use PowerShell.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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