Forum Discussion

ChenChristyYu's avatar
ChenChristyYu
Helper II
8 years ago
Solved

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.

 

  • 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

  • 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

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    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.

  • 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

    • ChenChristyYu's avatar
      ChenChristyYu
      Helper II

      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

      • TomMartens's avatar
        TomMartens
        Super User
        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