web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How do I format CSV to...
Power Automate
Unanswered

How do I format CSV to proper format to be uploaded into Smartsheet using Data Shuttle?

(0) ShareShare
ReportReport
Posted on by 93

I have vendor data exported into CSV that I'd like to upload into Smartsheet using Data Shuttle. However, the vendor data is exported in this format which the importing tool can't read. :

ljkeefe_0-1698856718905.png

Is there a way to program Power Automate to automatically grab the CSV from the source, then format it like this, so that it can import into Smartsheet? 

ljkeefe_1-1698856804683.png

 

I am not extremely familiar with Power Automate so I have no code to share because I don't know where to even begin. I've created some very simple flows but that's the extent of my skills.

Any help is appreciated.

Thanks!

Categories:
I have the same question (0)
  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    This is how I would build the flow to get what you're after.

     

    Below is the CSV file that I want to transform.

    grantjenkins_0-1698930385366.png

     

    Below is the full flow. I'll go into each of the actions.

    grantjenkins_6-1698931117007.png

     

    Get file content using path retrieves the content from the CSV I want to transform. I'm not sure how you are getting this content into your flow.

    grantjenkins_2-1698930486615.png

     

    Compose converts the content to a string using the following expression.

     

    base64ToString(outputs('Get_file_content_using_path')?['body']?['$content'])

     

    grantjenkins_3-1698930543757.png

     

    Filter array splits the data by carriage return and new line then removes any empty rows (normal get an empty row at the end after splitting the data). The expressions used are:

     

    //From
    split(outputs('Compose'), decodeUriComponent('%0D%0A'))
    
    //Condition
    item()

     

    grantjenkins_4-1698930669042.png

     

    Select uses the body of the Filter array and the following expressions. Note that the column names should be called col0, col1, col2, etc. as shown.

     

    split(item(), ',')?[0]
    split(item(), ',')?[1]
    split(item(), ',')?[2]
    split(item(), ',')?[3]
    split(item(), ',')?[4]
    split(item(), ',')?[5]
    split(item(), ',')?[6]
    split(item(), ',')?[7]
    split(item(), ',')?[8]
    split(item(), ',')?[9]
    split(item(), ',')?[10]
    split(item(), ',')?[11]
    split(item(), ',')?[12]

     

    grantjenkins_9-1698931183320.png

     

    Create CSV table uses the following expressions.

     

    //From
    range(1, 12)
    
    //Month (note this is index 1 to get the month)
    body('Select')[1][concat('col', item())]
    
    //Year (note this is index 0 to get the year)
    body('Select')[0][concat('col', item())]
    
    //Residential
    body('Select')[2][concat('col', item())]
    
    //Multifamily
    body('Select')[3][concat('col', item())]
    
    //Commercial
    body('Select')[4][concat('col', item())]
    
    //Grand total
    body('Select')[5][concat('col', item())]

     

    grantjenkins_8-1698931170136.png

     

    Create file uses the output from Create CSV table to create a new CSV file with the transformed data. Note that I've just added an expression to build up a dynamic date part for the file name - you can do whatever you want here.

     

    formatDateTime(utcNow(), 'yyyyMMdd-hhmmss')

     

    grantjenkins_10-1698931296593.png

     

    After running the flow I will get a new CSV file that looks like the example below.

    grantjenkins_11-1698931423818.png

  • ljkeefe Profile Picture
    93 on at

    @grantjenkins Thank you for the response. I tried the solution and got this error. Any idea why I would get this? I reviewed the inputs and they all look correct.

    ljkeefe_0-1698946219131.pngljkeefe_1-1698946241240.png

    This is the Month input 

    ljkeefe_2-1698946432594.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Are you able to show the rest of your flow to try and workout where the issue is?

  • ljkeefe Profile Picture
    93 on at

    @grantjenkins I tried my best to snapshot the flow onto a Word doc. I hope this helps.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Everything looks ok. Are you able to run your flow and check what you get as output from each of the actions to try and see if you can identify the root cause. So look at the output from the Compose then Filter array then Select, etc. to see if the data looks to be ok, and where it might be coming back incorrect.

  • ljkeefe Profile Picture
    93 on at

    @grantjenkins Thank you for taking a look. I thought it looked correct as well. Yes, I've run the flow and it gets stuck Create CSV (as shown above) and it gives me the array error. I will try again. Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard