Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Append multiple CSV from SharePointFolder and transform table

Hi Guys

 

I am trying to append dynamicly some CSV-Files from a SharePointFolder. Means, whenever a new file is being saved in this sharepoint folder, I want to have the new data.

 

I already can get all the files from the folder. Now I just have to transform and combine the data.  

I am struggeling with the final steps in transforming: Since it is a CSV, i need to split the data, remove first row and set the (now new row) as header.  Maybe you guys can help me.

 

Get the CSV's from a SharePointFolder

 

 

 

let
    Source = SharePoint.Files("sharepoint-address", [ApiVersion = 15]),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Folder Path], "sharepoint-path")),
    #"FilteredContent" = List.Transform(#"Filtered Rows"[Content], each Transform(_)),
    #"Result" = Table.Combine(#"FilteredContent")
in
    #"Result"

 

 

 

Function "Transform"

 

 

 

let
    Source = (input) => Table.FromColumns({Lines.FromBinary(input)}),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3", "Column1.4", "Column1.5", "Column1.6", "Column1.7", "Column1.8", "Column1.9", "Column1.10", "Column1.11"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", type text}, {"Column1.4", type text}, {"Column1.5", type text}, {"Column1.6", type text}, {"Column1.7", type text}, {"Column1.8", type text}, {"Column1.9", type text}, {"Column1.10", type text}, {"Column1.11", type text}}),
    #"Removed Top Rows" = Table.Skip(#"Changed Type",1),
    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"K", type text}, {"P", Int64.Type}, {"Time", type datetime}, {"Desc", type text}, {"A", type text}, {"B", type text}, {"C", type text}, {"D", type text}, {"Value", type text}, {"User", type text}, {"Q", type text}})
in
    Source

 

 

 

I do get a result, but the final steps (split, header row,...) are not applied. What am I doing wrong?

 

Best

Aleks

  • @reneton here is an excellent post that walks about this process.

    Check out my latest blog post Year-2020, Pandemic, Power BI and beyond to get a summary of my favorite versions of Power BI features in 2020

    I'd like to Compliments if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to congratulate anyone who has helped solve your problem. It's a show of thanks!

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultation.

3 Replies

  • @reneton here is an excellent post that walks about this process.

    Check out my latest blog post Year-2020, Pandemic, Power BI and beyond to get a summary of my favorite versions of Power BI features in 2020

    I'd like to Compliments if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to congratulate anyone who has helped solve your problem. It's a show of thanks!

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultation.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sweet 😁 Exactly what I needed!

      Just modified the source and voilà.

       

      Thank you very much.

       

      Best

      Aleks

  • Anonymous glad it worked out for you, accept it as a solution so that others can find it useful as well.

     

    Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.